jQuery validation plugin doesn't work for me
- by Idsa
I have the following code to enable validation work:
$(document).ready(function() {
$("#eventForm").validate({
rules: {
startDate: "required",
startTime: "required",
endDate: {
required: function (element) {
var endTimeValue = $('#endTime').val();
return (endTimeValue != null && endTimeValue != '');
}
},
endTime: {
required: function (element) {
var endDateValue = $('#endDate').val();
return (endDateValue != null && endDateValue != '');
}
}
},
messages: {
startDate: "Please enter event local start date",
startTime: "Please enter event local start time"
},
errorPlacement: function (error, element) {
error.appendTo(element.parent().next());
},
submitHandler: function (form) {
var options = {
dataType: 'json',
success: eventCreationSuccess,
error: eventCreationError
};
alert('submit');
//$(form).ajaxSubmit(options);
}
});
});
But validation plugin doesn't catch submit - default submit is executed.
jQuery and validation plugin scripts are imported.