GithubHelp home page GithubHelp logo

paralax / formvalidation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from drroach/formvalidation

0.0 2.0 0.0 111 KB

Simplest JavaScript form validation

License: GNU General Public License v3.0

CSS 2.21% JavaScript 97.79%

formvalidation's Introduction

FormValidation

Simple to implement jQuery form validation plugin. Add validation to your input fields simply be adding HTML fields to them. An example may look like this:

<input type="text" fv-email="This must be a valid email." name="email" placeholder="Email">

Validation Features

Feature Requests

fv-not-empty

Make sure that a input field isn't empty

Example:

fv-not-empty="This field can't be empty"

fv-email

Make sure that a input field has a valid email address

Example:

fv-email="This field must be a valid email address"

fv-simple-email

Much simpler email check that only looks for @ in input. This may be a better choice for large-scale production use where the 0.1% of emails that may fail the fv-email check will not fail.

Example:

fv-simple-email="This field must be a valid email address"

fv-number

Make sure that a input field has a valid number

Example:

fv-number="This field must be a number"

fv-alphanum

Make sure that a input field has a alpha-numeric value

Example:

fv-alphanum="This field must be a alpha-numeric value"

fv-func

Add some JavaScript code to be ran to which will either return true or a error messsage. This is useful when you want to make sure a variable has a certain value for example. You can also use "this" in a fv-func call to reference the current inputs' value

Example:

fv-func="this == 'I\'m Human!' ? true : 'It looks like you\'re not human'"

You can also use JavaScript variables in here

Example:

fv-func="loading == false ? true : 'The page is loading'"

fv-advanced

You can pass a JSON object to this validation method to perform more advanced validation

min

The minimum number of characters that this input field has to have

max

The maximum number of characters that this input field can have

regex

Write a regular expression to match against the field input

regex_reverse

Boolean that can tell our checks to fail on the inverse of our regular expression. For example, say you don't want any whitespace in your input. Setting this value to true will throw your error if it finds any whitespace. Rather than trying to force whitespace only.

message

The error message that is displayed when a condition isn't met

Example:

fv-advanced='{"min": "6", "max": "10", "regex": "\\w+", "message": "This value must be at least 6 characters long."}'

Setup

You can pass some extra setup data such as custom classes so the whole plugin is easier to work with. You can do this by calling formValidator.setup() or FV.setup() in your code.

Example:

FV.setup({
    errorMessageClasses: "col-xs-12 col-sm-8 col-md-4"
});
errorMessageClasses

Pass in a string of classes to be added to error messages

Example:

errorMessageClasses: "col-xs-12 col-sm-8 col-md-4"

formvalidation's People

Contributors

drroach avatar

Watchers

jose nazario avatar  avatar

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.