I have a form that has multiple inputs array, but I just want some that are mandatory, which you want to apply the class ignoring ignore. the problem is that jquery validate check all mandatory. How could I avoid this:
a simple example:
html
<form id='register' name='register' method='post' action='' >
enter code herearray1: <input type='text' name='name[]' id='name'/>
input type 1: <input type='text' name='name[]' id='name'/>
input type 1: <input type='text' class="noValidate" name='name[]' id='name'/>
input type 1: <input type='text' name='name[]' id='name'/>
<input type='submit' name='Submit' value='Submit' />
</form>
function that validate the form
function ValidateFormNewContract()
{
$('#formAltaContrac').submit(function(event)
{
event.preventDefault();
$('#formAltaContrac').validate().settings.ignore = [];
});
$('#formAltaContrac').validate(
{
ignore: ".noValidate",
invalidHandler: function(e,validator)
{
if(validator.errorList.length > 0)
{
var id = $(validator.errorList[0].element).parent().parent().parent().parent().parent()[0].id;
$('a[href=#'+id+']').click();
$(validator.errorList[0].element).focus();
}
},
submitHandler: function(form) {
// alert('enviado');
SendNewContractData();
},
rules: {
'name[]':{required: true},
//
}
});
}
note: I have modified jquery validate to perform validations array inputs,
validations array inputs makes them well, but do not get to ignore the class
and another question, how could I do to make the span Feeding Fail jquery to validate an input spread to other inputs to array fault?
name
more than once. jQuery Validate plugin uses thename
to keep track of inputs so it must be unique. – Sparky May 29 '14 at 19:33