10

This may be a very stupid question but i am looking for a list of the inline validation rules for the jquery form validator.

I know that i can find the js functions here:

but i am looking for a list of the simple inline classes like

email, url, phone, etc., and learn how to use them. I am just looking for a simple list. Thank you.

Andrew Whitaker
  • 124,656
  • 32
  • 289
  • 307
user982853
  • 2,470
  • 14
  • 55
  • 82
  • 1
    Thanks for asking this. The first example in the documentation uses classes to define the rules, but the rest of the documentation makes no additional mention of this. – Tuan Jun 12 '12 at 17:29

2 Answers2

21

Looking at the source, I believe these are the only rules that can be used simply by adding classes:

  • required
  • email
  • url
  • date
  • dateISO
  • number
  • digits
  • creditcard

As for how to use them, just add them into the class attribute of your input:

<input type='text' class='required creditcard' name='credit-card' />

You'll have to define other rules in the object you pass to validate.

Garland Pope
  • 3,242
  • 1
  • 25
  • 19
Andrew Whitaker
  • 124,656
  • 32
  • 289
  • 307
  • So is there a way to define these validations in the call but by class not field name? – user982853 Feb 19 '12 at 22:37
  • @user982853: I'm not sure what you mean--If you want to define rules in the `validate` call you must use field names. Additionally, if you apply the class rules to elements, they must have a `name` to be validated correctly. – Andrew Whitaker Feb 20 '12 at 15:04
6

Most probably you are looking for this

http://elegantcode.com/wp-content/uploads/2010/03/Jquery-Validator-Cheat-sheet.pdf

Founded when I was looking for same easy to remember list of validation plugin rules. :)

Update: If you like to have all things together try this too:

http://marketblog.envato.com/resources/extensive-collection-cheatsheets-web-designers

Adrian P.
  • 5,060
  • 2
  • 46
  • 47