html - Validating and submitting - form inputs with two dimensional element -


i have form fieldset follows. inputs dynamically generated based on number entered in prior input field using jquery. first dimension of 2-dimentional array index generated inside loop.

<fieldset id="accompanying"> <legend>accompanying members</legend> <p> <input type="text" name="members[0][firstname]" placeholder="enter first name"> <input type="text" name="members[0][lastname]" placeholder="enter last name"> <input type="text" name="members[0][age]" style="width: 30px;" placeholder="age"> <br> <br> <input type="text" name="members[1][firstname]" placeholder="enter first name"> <input type="text" name="members[1][lastname]" placeholder="enter last name"> <input type="text" name="members[1][age]" style="width: 30px;" placeholder="age"> <br> <br> <input type="text" name="members[2][firstname]" placeholder="enter first name"> <input type="text" name="members[2][lastname]" placeholder="enter last name"> <input type="text" name="members[2][age]" style="width: 30px;" placeholder="age"> <br> <br> </p> </fieldset> 

i never had send multidimensional array of input elements before , not sure how in codeignitor. saw post on stackoverflow (see accepted answer)

i using jquery validate plugin on form , not clear on how validate fields above. fields required. saw post using one-dimensional array here

any ideas ?

quote op:

"i using jquery validate plugin on form , not clear on how validate fields above. fields required."

the simple thing add class="required" applicable input elements.

<input type="text" name="members[0][firstname]" class="required" placeholder="enter first name" /> 

then have call .validate() initialize plugin on form.

$(document).ready(function() {      $('#myform').validate();  }); 

http://jsfiddle.net/j4uea/

jquery validate client-side validation, don't forget implement the server-side form validation built codeigniter.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -