jQuery validation plugin doens't work for me

Posted by Idsa on Stack Overflow See other posts from Stack Overflow or by Idsa
Published on 2010-04-05T12:51:40Z Indexed on 2010/04/05 12:53 UTC
Read the original article Hit count: 286

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-validate