| Option | Description | Possible Values | Default |
|---|---|---|---|
| required | [Determines if element is required] | true or false | false |
| validation | [Specifies what type of validation type an element has] | number, phone, url, email, zip | "none" |
| type | [Used for input to determine what type of input to append] | text, password | "text" |
| action | [Form attribute to indicate where the form should submit to] | 'ex. send_email.php' | "" |
| method | [Form attribute to indicate whether to use the POST or GET method] | POST, GET | "" |
| name | [Sets the name attribute for an element] | ex. "my_input" | "" |
| labelValue | [The value of the label associated with a certain element] | Any string | No label element will be rendered |
| value | [Used for buttons to set their value] | Any string | "Submit" |
| labelClass | [Class for the label of a given element] | Any string | Depends on element |
| labelID | [ID for the label of a given element] | Any string | Depends on element |
| className | [Class attribute to be given to an element] | Any string | Depends on element |
| id | [ID attribute to be given to an element] | Any string | Depends on element |
| name | [Name attribute to be given to an element] | Any string | Depends on element |
| rows | [Number of rows for a textarea] | "#" | "5" |
| cols | [Number of columns for a textarea] | "#" | "30" |
| multiple | [Determines wether a select is a multiple select] | true or false | false |
| legend | [The value of a legend within a fieldset. Used for radios and checkboxes] | Any string | "" |
| number | [Sets the error message for number validation] | Any string | "Numbers only." |
| url | [Sets the error message for url validation] | Any string | "Invalid URL." |
| [Sets the error message for e-mail validation] | Any String | "Invalid e-mail." | |
| zip | [Sets the error message for zip code validation] | Any String | "Invalid zip code." |
| phone | [Sets the error message for phone number validation] | Any String | "Invalid phone number." |
| blank | [Sets the error message for blank field validation] | Any String | "Please complete this field." |
| captcha | [Sets the error message for captcha field validation] | Any String | "Incorrect Captcha answer." |
| isAjax | [Suppresses the default form submit action (for things like an AJAX form submit)] | true or false | false |
| Note: The captcha feature will display the questions randomly. | |||
| captchaQuestions | [Used for Captcha. Associative array of questions and answers for captcha.] | {'question':'answer'} | Random assortment of my own captcha questions |
| autoComplete | [Turns autocomplete on or off] | "on"" or "off" | "on" |
$(document).ready(function(){
$("#demo").formation();
$.formation.addInput({type:"text",labelValue:"First Name:",required:true, defaultValue:"Matt"});
$.formation.addInput({type:"text",labelValue:"Last Name:",required:true});
$.formation.addInput({type:"text",labelValue:"E-mail:",validation:'email',required:true});
$.formation.addInput({type:"text",labelValue:"Age:",validation:"number"});
$.formation.addRadios(["Mac","Linux","Windows","Ubuntu"],{
required:true,
labelValue:"Your favorite OS:",
legend:"Operating Systems"
});
$.formation.addCheckboxes({"apples":"Apples","oranges":"Oranges","grapes":"Grapes"},{labelValue:"What do you like to eat?",required:false,legend:"Fruit!"});
$.formation.addCaptcha({
captchaQuestions: {
'5 + 5 = ?' : '10',
'What color is the sky?':'blue',
'2 + 2 = ?' : '4'
},
required:true
});
$.formation.addTextarea({
name:"my_textarea",
labelValue:"Describe yourself",
required:true,
cols:"60",
rows:"10"
});
$.formation.addSelect({'1':'Yes','2':'No'},{labelValue:'Do you like jQuery?',required:true});
$.formation.setErrorMessages({number:"Please enter a number."});
$.formation.addButton({value: "SUBMIT"});
$.formation.addButton({value: "RESET",type:'reset'})
}