Code Monkey home page Code Monkey logo

formvalidator's Introduction

formvalidator

Formvalidator is a jQuery plugin that performs basic field validation based on html attributes. When called on an element containing data fields (such as a form element) the plugin traverses to the data fields and returns a collection of invalid fields.

The plugin uses several html data attributes to perform its validation: 'data-vrule', 'data-vminval', 'data-vmaxval', 'data-vregex', and 'data-verror'. The first attribute, 'data-vrule', sets the validation rule to be applied to the element. If 'data-vrule' is not present the field is ignored and assumed valid. The next three attributes are optional parameters used in various validation rules as described below.

The last attribute, 'data-verror', is set by the plugin on each element that is returned by the plugin and contains a message describing the validation error.

The validation rule for the field is set using the 'data-vrule' attribute. The following rules are supported:

notemptyThe field cannot be empty
minlengthfield has a minimum length specified in 'data-vminval'
maxlengthfield has a maximum length specified in 'data-vmaxval'
lenbetweenfield must have a length between the values in 'data-vminval' and 'data-vmaxval' inclusive
valbetweenfield must have a value between the values in 'data-vminval' and 'data-vmaxval' inclusive
isnumericfield must be a valid number (float or integer)
isalphafield only contains the letters a-z
isalphanumericfield only contains the letters a-z and numbers 0-9
isemailfield appears to be a valid email address
matchregexfield matches the regular expression given in 'data-vregex'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.