JQuery form validation: standard box dialog when field is invalid

I need a very simple client-side validation: whenever an invalid field is encountered, a standard Windows dialog is displayed, stop validating the remaining fields and cancel the submission.

What's the easiest way to do this with jQuery?

0


a source to share


2 answers


You can try to mark all fields required for validation with the "RequiredField" class and then use Jquery to validate them right away. For those that don't work, you can add a selection class to turn them, say, red.

After that, you can show a warning that says the highlighted fields are invaild.



function CheckStandardInputs () {// Check the required fields. var ReqFields = $ (". RequiredField [value = '']");

if(ReqFields.size() > 0){
    if(HighlightBlanks){
        ReqFields.addClass("Highlight");
    }
            //Remove highlight on change.
    ReqFields.change(function () {$(this).removeClass("Highlight");});
    return false;
}else{
    return true;
}

      

}

+2


a source


What's wrong with the standard jQuery validation plugin ?



+1


a source







All Articles