Skip to content
validfield.js helps you quickly validate your forms
JavaScript HTML
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
README.md
bower.json
index.html
validfield.js
validfield.min.js

README.md

validfield.js

What is it?

validfield.js helps you to quickly validate your forms with ease

  • No ninja JavaScript skills needed
  • It's tiny! Just 4KB!
  • Easy to customize
  • Allows callback functions

View the demo


Installation

  • Install via Bower bower install --save validfield
  • Download via GitHub

How to use?

First, include the validfield.js in your HTML document.

Then add the class valid-field to the form you need to validate:

<form action="page.php" name="form" id="form" class="valid-field" data-valid-field-keypress-check="yes">...</form>

Additionally, you can add the extra attribute data-valid-field-keypress-check in the form field, to validate the inputs on key press.

Afterwards, just add the attributes to the fields that you want to validate. For example:

<input name="form" type="text" data-valid-field-type="min-length" data-valid-field-minimum-length="5">

The attribute data-valid-field-type is the key, used by validfield.js to validate your form fields. There are many validation types available. Check them out:

  • min-length checks for a minimum number of characters
  • min-equal-length checks for a minimum or exact number of characters
  • max-length checks for a maximum number of characters
  • max-equal-length checks for a maximum or exact number of characters
  • email checks for a valid email
  • url checks for a valid URL
  • date checks for a valid date
  • custom needed if you need to create your own validation method

Help?

Check the demo to see with clarity how to use validfield.js.

Tweet me if you have any questions. Bug fixes and pull requests are highly appreciated.

Hope you enjoy :)


License

GNU GPL

Peace!

Something went wrong with that request. Please try again.