1

I currently have a set of inputs that look like this:

<li class="required">
    <label>First Name</label>
    <input type="text" name="cf_member_address[row_id_52][col_id_19]" value="">
</li>
<li class="required">
    <label>Surname</label>
    <input type="text" name="cf_member_address[row_id_52][col_id_20]" value="">
</li>

and I'm using jQuery validate to validate the form before it submits. I'm trying to add custom messages to each item but i've hit a problem because of the arrays ([row_id_52])

Also, depending on the form that loads, depends on what row ID shows ([row_id_52]) - But the Col ID stays the same.

How can I declare:

  • An Array input field that has a dynamic number in it?

In my JS file? I'm currently doing it like this:

cf_member_first_name: "Please enter your First Name",

Any help would be appreciated!

Jason Mayo
  • 356
  • 1
  • 3
  • 23
  • Sorry Jason, I don't understand what you are trying to say. Is there a link so we can see the problem too? – sisko Oct 25 '12 at 15:34
  • 1
    Doesn't class="required" need to be on the actual required? ? Also, if I am reading this correct, maybe this will help: http://stackoverflow.com/questions/4526229/jquery-validation-for-array-of-input-elements – jasonflaherty Oct 25 '12 at 15:40
  • @sisko I'm basically trying to get my cf_member_address[row_id_52][col_id_20] input field to have a custom error message. jQuery Validate plugin doesn't like that it's using an Array for the name of the field, so I need to figure a way around this. – Jason Mayo Oct 25 '12 at 18:32
  • @buildakicker I forgot to mention that the class="required" is being added dynamically. So when I set the class="required" on the
  • element, it adds it to the input fields as well, and adds an asterisks next to the label. It just saves me doing it on every input.
  • – Jason Mayo Oct 25 '12 at 18:33