Created
November 23, 2010 06:49
-
-
Save snikch/711376 to your computer and use it in GitHub Desktop.
A spec for a light weight jQuery validation plugin with schemas not classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Must NOT use class="required" validation | |
* Must use Javascript objects for validation | |
var schema = { | |
options : { | |
'bubble' : true, // Bubble validation checks to all elements, if false will stop on fail | |
'blur' : false, // Will not call the validate method on the inputs | |
'auto' : false, // Will not attempt to apply to all forms, just ID matched forms | |
'decorator' : 'inline' // Defaults to supplied decorator, but a decorator can be supplied | |
}, | |
// Create custom rules / defaults. These will automagically match input names | |
rules : { | |
name : { | |
minlen: {3, 'Name must be at least 3 characters'}, | |
maxlen: {100, 'Name must not be more than 3 characters'} | |
}, | |
twitter : function(val){ | |
.... return true if a valid twitter name (query api) | |
} | |
}, | |
'#newarticleform' : { | |
// Use a custom twitter validation rule, must have been passed | |
twittername : {{'twitter', 'Please select a valid twitter username'}}, | |
othertwittername : {'twitter'} // use default message | |
} | |
} | |
* Use HTML5 element types to add validation rules (email, url, date) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment