SimpleValidate simple validation plug in based on jquery

  • 2020-03-30 01:36:21
  • OfStack

If you don't need to do instant validation with onfocus and onblur, if you don't want to define validation rules for every table with JS, if you only need one validation and feedback at the time of submission, and if you like simple code structures, I think simpleValidate is a good choice.

Define the data-rules property:
Distinguish multiple verification rules with the well sign "#", attach the verification pair ratio with the plus sign "+", attach the feedback item title with the horizontal bar "-", and write the following basic methods


<input type="text" name="email" value="@" data-rules=" email -required# email -valid_email" />
<input name="password" id="txt_pass" type="password" data-rules=" password -min_length+8# password -max_length+16" />
<input name="password2" type="password" data-rules=" Confirm password -matches+txt_pass+ password " />

Define that all forms are validated before submission:


$('form').bind('submit',function(){
    var message=$(this).validate();
    if(message!==true){
        alert(message);
        return false;
    }
    return true;
});

Open source address of the project: (link: https://github.com/capucinno-lee/jquery-simple-validation)
The DEMO address: (link: http://demo.jb51.net/js/2014/jquery_simple_validation/)


Related articles: