项目作者: rickharrison

项目描述 :
Lightweight JavaScript form validation library inspired by CodeIgniter.
高级语言: JavaScript
项目地址: git://github.com/rickharrison/validate.js.git
创建时间: 2011-10-14T05:05:04Z
项目社区:https://github.com/rickharrison/validate.js

开源协议:Other

下载


validate.js

validate.js is a lightweight JavaScript form validation library inspired by CodeIgniter.

Features

  • Validate form fields from over a dozen rules
  • No dependencies
  • Customizable Messages
  • Supply your own validation callbacks for custom rules
  • Chainable customization methods for ease of declaration
  • Works in all major browsers, (even IE6!)
  • Modeled off the CodeIgniter form validation API

How to use

  1. var validator = new FormValidator('example_form', [{
  2. name: 'req',
  3. display: 'required',
  4. rules: 'required'
  5. }, {
  6. name: 'alphanumeric',
  7. rules: 'alpha_numeric'
  8. }, {
  9. name: 'password',
  10. rules: 'required'
  11. }, {
  12. name: 'password_confirm',
  13. display: 'password confirmation',
  14. rules: 'required|matches[password]'
  15. }, {
  16. name: 'email',
  17. rules: 'valid_email'
  18. }, {
  19. name: 'minlength',
  20. display: 'min length',
  21. rules: 'min_length[8]'
  22. }, {
  23. names: ['fname', 'lname'],
  24. rules: 'required|alpha'
  25. }], function(errors) {
  26. if (errors.length > 0) {
  27. // Show the errors
  28. }
  29. });

Documentation

You can view everything at http://rickharrison.github.com/validate.js

Browserify

It is published to npm under validate-js

  1. npm install validate-js

Plugins

jQuery: https://github.com/magizh/validate_helper

Multi-Language Support

jnhwkim’s fork added multi-language support viewable at https://github.com/jnhwkim/validate.js

Chinese - https://github.com/chilijung/validate.js

French - https://github.com/Facyla/validate.js

Brazilian Portuguese - https://github.com/fabiowitt/validate.js

ghit.me