PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Custom Validate Name (don't allow numbers)

  1. Let's say I have a form and I am using gform_validation and the name advanced field(because I do) that is outputing

    <input type="text" tabindex="1" value="" id="input_4_2.3" name="input_2.3">
    <input type="text" tabindex="2" value="" id="input_4_2.6" name="input_2.6">

    With my other custom validation i'm able to use $_POST[input_4_#]; but for some reason $_POST[input_4_2.3]; dosen't work.

    Really all I want to do is not allow people to use numbers as their name. This should be a simple regex I just need to figure out how to get the Value of input 4_2.6 and 4_2.3.

    Thanks

    Posted 13 years ago on Monday April 4, 2011 | Permalink
  2. Hi Brooke,

    $_POST keys for radio, checkboxes, and advanced fields containing multiple inputs will follow this format:

    input_{field_id}_{input_index}

    So if the field's name is "input_2.3", this could be access in the $_POST like this: $_POST['input_2_3'].

    Posted 13 years ago on Monday April 4, 2011 | Permalink
  3. Thanks, that did the trick. I put in a feature request here http://www.gravityhelp.com/forums/topic/simple-custom-validation to request this process be simpler. I also have a quick question with custom validation like $form["fields"][4]["failed_validation"] = true; where does the [4] come from? I know that's where the validation shows up but it seems to be independent from field number. From what I've gathered it's the position of the field starting with 0 so 4 would be the 3rd input field. Is this correct?

    Posted 13 years ago on Tuesday April 5, 2011 | Permalink

This topic has been resolved and has been closed to new replies.