errorClass in jquery validate plugin?

前端 未结 6 1043
悲哀的现实
悲哀的现实 2020-12-14 07:58

I am using jquery validate plugin in my web application to validate forms for blank and other simple validations.

I am using below code to setup jquery validate plug

6条回答
  •  爱一瞬间的悲伤
    2020-12-14 08:47

    Check this:

    jQuery.validator.messages.required = "";
    $('#frm-contact').validate({
        invalidHandler: function (e, validator) {
            var errors = validator.numberOfInvalids();
            if (errors) {
                var message = errors == 1
                        ? 'You missed 1 field. It has been highlighted below'
                        : 'You missed ' + errors + ' fields.  They have been highlighted below';
                $("div.error span").html(message);
                $("div.error").show();
            } else {
                $("div.error").hide();
            }
        },
        onkeyup: false,
        submitHandler: function () {
            $("div.error").hide();
            alert("submit! use link below to go to the other step");
        },
        highlight: function (element, required) {
            $(element).fadeOut(function () {
                $(element).fadeIn();
                $(element).css('border', '2px solid #FDADAF');
            });
        },
        unhighlight: function (element, errorClass, validClass) {
            $(element).css('border', '1px solid #CCC');
        }
    });
    

提交回复
热议问题