How can I refer to the second input in this jsfiddle while defining validation rules? I am thinking at something like "postArray.inputOne" instead of inputOne, as I do for the first one. Of course, it doesn't work. Is there any way I can do it?
My HTML looks like this:
<form id="formId" method="post" action="">
<input type="text" name="inputOne" />
<input type="text" name="postArray[inputOne]" />
</form>
The validation rules look like this:
$("#formId").validate({
rules: {
inputOne: {
required: true
}
},
messages: {
inputOne: {
required: "Required!"
}
}
});
Thanks!
You can validate any text field by name
$(document).ready(function () {
$("#formId").validate({
rules:{
"inputOne":{
required:true
},
"postArray[inputOne]":{
required:true
},
messages:{
"inputOne":"This field is required",
"postArray[inputOne]":"This field is required"
}
}
});
});
Hope it will help.....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With