$("#passenger_info").validate({
errorPlacement: $.noop,
ignore: ".ignore_val",
rules: {},
invalidHandler: function (form, validator) {
var errors = validator.numberOfInvalids();
if (errors) {
validator.errorList[0].element.focus();
}
$("input.first-name").each(function () {
if ($(this).val() == "" && $(this).val().length < 1) {
$(this).addClass("error");
} else {
$(this).removeClass("error");
}
});
},
submitHandler: function (form) {
var isValid = true;
$("input.first-name").each(function () {
if ($(this).val() == "" && $(this).val().length < 1) {
$(this).addClass("error");
isValid = false;
} else {
$(this).removeClass("error");
}
});
if (isValid) {
form.submit();
}
},
});
checkForm: function() {
this.prepareForm();
for (var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++) {
if (this.findByName(elements[i].name).length != undefined && this.findByName(elements[i].name).length > 1) {
for (var cnt = 0; cnt < this.findByName(elements[i].name).length; cnt++) {
this.check(this.findByName(elements[i].name)[cnt]);
}
} else {
this.check(elements[i]);
}
}
return this.valid();
}
checkForm: function() {
this.prepareForm();
for (var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++) {
if (this.findByName(elements[i].name).length != undefined && this.findByName(elements[i].name).length > 1) {
for (var cnt = 0; cnt < this.findByName(elements[i].name).length; cnt++) {
this.check(this.findByName(elements[i].name)[cnt]);
}
} else {
this.check(elements[i]);
}
}
return this.valid();
}