Validation Rules Method and Syntex


Syntex :

$(function(){
$(“#login_form”).validateset({
rules: {
fieldname: { method },
},
messages: {
fieldname: { method },
}
});
});

Required JS File :

<script src=”js/jquery.js” type=”text/javascript”></script>
<script src=”js/jquery.validate.min.js” type=”text/javascript”></script>

Predefine Method :

  • Required: The typical and probably most used validation out there.
  • Minlength & Maxlength: Staple Length validation rules
  • Rangelength: Similar to Min/Maxlength; allows for selected item counts as well.
  • Min & Max & Range: Same as the “length” rules above only for numeric values.
  • Email: A very robust email validation rule
  • Url: Ensures the input is a well formatted url.
  • Date: Verifies the input can be parsed into a date.
  • Number: Ensures that the input is numeric.
  • Digits: Ensures only 0-9 characters (no commas, decimal points, etc.)
  • Credit Cards: Another complex and common validation rule made easy.
  • Accept: A file extension validation rule.
  • EqualTo: Ensures that the values of 2 elements are the same.

Leave a comment