Skip to content
The simply to use jquery plugin for validate fields
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
example
README.md
jquery.simply-validate.js

README.md

jquery Simply Validate

this is short plugin for validate fields.

You need to do:

  • Add plugin to page
  • Add event, to form submit

as example, look in "example/index.html". Short and work example.

To call validate, you need find Form jquery examplar and find in form all input and textarea elements: $('#form').find('input, textarea').validate();

If you want to set other popup default error text, re-define in pligun

var validateEmailError = 'Wrong email adress';
var validateRequiredError ='Fields is required';
var validateRepasswordError = 'Password do not match';
var validateCheckedError = 'You do not accept the license agreement?';

If you want to change text, or add some actions to validate, call validate method with argument 'callback'

$('#form').find('input, textarea').validate(function(item, defaultErrorMessage, showPopupFn) {
    // Here you get. item - jquery exemplar for current validated input
    // defaultErrorMessage - default error text for this input
    // showPopupFn - function, show popup message at field.
        // Popup get next arguments:
        // item - jquery exemplar for current current validated input
        // errorText - new error text message
        // timeout=5 - Timeout for remove current popup, as default = 5
});

To define, how type validate you need, added to input field in HTML one data-type attribute. Named is data-valid. Data valid has 4 params (at this revision).

  • require - Fields is need required
  • email - Email validate as regular expression
  • checked - Used in checkbox and if not checked, show error message
  • re-password - if field need to mutch with other input, use this value, but, re-password need some more attribute. data-target value need query selector for target element. See example for more detail```
Something went wrong with that request. Please try again.