I'm using a jquery validation plugin
First I add the validation to the form:
$('#EmployeeForm').validate({
rules: {
"Employee.FirstName": "required",
"Employee.PatronymicName": "required",
"Employee.LastName": "required",
"Employee.BirthDay": { required: true, date: true }
},
messages: {
"Employee.FirstName": { required: "*" },
"Employee.PatronymicName": { required: "*" },
"Employee.LastName": { required: "*" },
"Employee.BirthDay": { required: "*", date: "00.00.00 format" }
}
});
It works fine until here. I then later a need to add validation rules to other form elements:
$('#Address_A.Phone1, #Address_A.Phone2, #Address_B.Phone1, #Address_B.Phone2')
.rules("add", {
digits: true
});
Here I get an error: 'form' is null or not an object
I check, the form and all the elements in it are created before I add validation to it.
I cant figure out what's wrong.