Hello!
I need a litle help to validate my form:
Now, i use this code to validate my form:
$(document).ready(function() {
$("#set_search").validate({
rules: {
q: {
required: true,
minlength: 2
},
q2: {
number: true
},
},
messages: {
q: "Please enter your name",
q2: "Only numbers allowed",
}
});
});
And i have this search form, in the for cycle:
for ($i=0;$i<5;$i++) {
echo "<div class='showhide$i'><form name='set_search' id='set_search' action='settings.php' method='get'><p><label for='q1'>name</label><input type='text' id='q' name='q'/></p><p><label for='q2'>number</label><input type='text' id='q2' name='q2' /></p><p><input type='submit' value='Search'/></p></form></div></p>";
}
Unfortunatelly with this code only the first search form is working and validated , and the next forms didnt. So i think:
i have to modify the from name and id to:
<
form name='set_search$i' id='set_search$i'
and i have to modify the validation to something like this:
var sr= $(this).attr('id'); $("#set_search" +sr).validate({
But this not ok. Could you help someone? Thx.