<p>Form validation requires passing in a validation object with the rules required to validate your form.</p>
<div class="ui info message">
<i class="help icon"></i>A validation object includes a list of form elements, and rules to validate each against. Fields are matched by either the <code>id</code> tag, <code>name</code> tag, or the <code>data-validate</code> metadata matching the identifier provided in the settings object.
@ -122,75 +122,79 @@ type : 'UI Behavior'
</div>
</div>
<h3 class="ui header">
Types of Validation Rules
<div class="sub header">Validation rules are a set of conditions required to validate a field</div>
</h3>
<div class="ui info message">Validation rules are found in <code>settings.rules</code>, to add new global validation rules, modify <code>$.fn.form.settings.rules</code> to include your function.</div>
<div class="in red message">To pass parameters to a rule, use bracket notation in your settings object. For example <code>type: 'not[dog]'</code></div>
<td>Checks whether a field is a valid email address</td>
</tr>
<tr>
<td>length</td>
<td>value</td>
<td>Checks whether a field is longer than a length</td>
</tr>
<tr>
<td>not</td>
<td>value, notValue</td>
<td>Checks whether a field is not a value</td>
</tr>
<tr>
<td>contains</td>
<td>value, text</td>
<td>Checks whether a field contains text</td>
</tr>
<tr>
<td>is</td>
<td>value, text</td>
<td>Checks whether a field matches a value</td>
</tr>
<tr>
<td>maxLength</td>
<td>value</td>
<td>Checks whether a field is less than a max length</td>
</tr>
<tr>
<td>match</td>
<td>value, fieldIdentifier</td>
<td>Checks whether a field matches another field</td>
</tr>
<tr>
<td>url</td>
<td>value</td>
<td>Checks whether a field is a url</td>
</tr>
<tr>
<td>checked</td>
<td>-</td>
<td>Checks whether a checkbox field is checked</td>
</tr>
</tbody>
</table>
<div class="no example">
<h4 class="ui header">
Validation Rules
</h4>
<p>Validation rules are a set of conditions required to validate a field</p>
<div class="ui info message">Validation rules are found in <code>$.fn.form.settings.rules</code>, to add new global validation rules, modify <code>$.fn.form.settings.rules</code> to include your function.</div>
<div class="in red message">To pass parameters to a rule, use bracket notation in your settings object. For example <code>type: 'not[dog]'</code></div>
<td>Checks whether a field is a valid email address</td>
</tr>
<tr>
<td>length</td>
<td>value</td>
<td>Checks whether a field is longer than a length</td>
</tr>
<tr>
<td>not</td>
<td>value, notValue</td>
<td>Checks whether a field is not a value</td>
</tr>
<tr>
<td>contains</td>
<td>value, text</td>
<td>Checks whether a field contains text</td>
</tr>
<tr>
<td>is</td>
<td>value, text</td>
<td>Checks whether a field matches a value</td>
</tr>
<tr>
<td>maxLength</td>
<td>value</td>
<td>Checks whether a field is less than a max length</td>
</tr>
<tr>
<td>match</td>
<td>value, fieldIdentifier</td>
<td>Checks whether a field matches another field</td>
</tr>
<tr>
<td>url</td>
<td>value</td>
<td>Checks whether a field is a url</td>
</tr>
<tr>
<td>checked</td>
<td>-</td>
<td>Checks whether a checkbox field is checked</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="ui tab" data-tab="examples">
<h2 class="ui dividing header">Examples</h2>
<div class="dropdown example">
<h3 class="ui header">Validating Dropdowns</h3>
<h4 class="ui header">Validating Dropdowns</h4>
<p><a href="/modules/dropdown.html">Dropdowns</a> can also be validated like other form fields. Simply match the validation rule to the hidden input associated with the dropdown</p>
<p>Forms that contain a <a href="/elements/message.html">ui message</a> error block will automatically be filled in with form validation information.</p>
<div class="ui ignored info message">The template for error messages can be modified by adjusting settings.template.error</div>
@ -278,7 +282,7 @@ type : 'UI Behavior'
</div>
<div class="inline example">
<h3 class="ui header">Validating on Blur and other Events</h3>
<h4 class="ui header">Validating on Blur and other Events</h4>
<p>Validation messages can also appear inline. UI Forms automatically format <a href="/elements/label.html">labels</a> with the class name <code>prompt</code>. These validation prompts are also set to appear on input change instead of form submission.</p>
<div class="ui ignored warning message">This example also uses a different validation event. Each element will be validated on input blur instead of the default form submit.</div>
<p>You can use multiple arbitrary rules to validate a form</p>
<div class="ignore code">
$('.ui.form')
@ -361,7 +365,11 @@ type : 'UI Behavior'
<div class="ui tab" data-tab="settings">
<h2 class="ui dividing header">Behavior</h2>
All the following <a href="/module.html#/behavior">behaviors</a> can be called using the syntax <code>$('.foo').form('behavior name', argumentOne, argumentTwo)</code>
All the following <a href="/module.html#/behavior">behaviors</a> can be called using the syntax
<td>Adds keyboard shortcuts for enter and escape keys to submit form and blur fields respectively</td>
</tr>
<tr>
<td>on</td>
<td>submit</td>
<td>Event used to trigger validation. Can be either <b>submit</b>, <b>blur</b> or <b>change</b>.</td>
</tr>
<tr>
<td>revalidate</td>
<td>true</td>
<td>If set to true will revalidate fields with errors on input change</td>
</tr>
<tr>
<td>delay</td>
<td>true</td>
<td>Delay from last typed letter to validate a field when using <code>on: change</code> or when revalidating a field.</td>
</tr>
<tr>
<td>inline</td>
<td>false</td>
<td>Adds inline error on field validation error</td>
</tr>
<tr>
<td>transition</td>
<td>
scale
</td>
<td>Named transition to use when animating validation errors. Fade and slide down are available without including <a href="/modules/transition.html">ui transitions</a></td>
<div class="sub header">Templates are used to construct elements</div>
</h3>
<div class="ui ignored info message">Templates are found in <code>settings.template</code>, to modify templates across all forms, modify <code>$.fn.form.settings.templates</code> to include your function. They must return html.</div>
<table class="ui celled definition table">
<thead>
<th class="four wide">Template</th>
<th>Arguments</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td>error</td>
<td>Errors (Array)</td>
<td>Constructs the contents of an error message</td>
</tr>
<tr>
<td>prompt</td>
<td>Errors (Array)</td>
<td>Constructs an element to prompt the user to an invalid field</td>
<td>Adds keyboard shortcuts for enter and escape keys to submit form and blur fields respectively</td>
</tr>
<tr>
<td>on</td>
<td>submit</td>
<td>Event used to trigger validation. Can be either <b>submit</b>, <b>blur</b> or <b>change</b>.</td>
</tr>
<tr>
<td>revalidate</td>
<td>true</td>
<td>If set to true will revalidate fields with errors on input change</td>
</tr>
<tr>
<td>delay</td>
<td>true</td>
<td>Delay from last typed letter to validate a field when using <code>on: change</code> or when revalidating a field.</td>
</tr>
<tr>
<td>inline</td>
<td>false</td>
<td>Adds inline error on field validation error</td>
</tr>
<tr>
<td>transition</td>
<td>
scale
</td>
<td>Named transition to use when animating validation errors. Fade and slide down are available without including <a href="/modules/transition.html">ui transitions</a></td>
</tr>
<tr>
<td>duration</td>
<td>150</td>
<td>Animation speed for inline prompt</td>
</tr>
</tbody>
</table>
</div>
<div class="no example">
<h4 class="ui header">
Callbacks
</h4>
<p>Callbacks specify a function to occur after a specific behavior.</p>
<div class="ui ignored info message">Templates are found in <code>settings.template</code>, to modify templates across all forms, modify <code>$.fn.form.settings.templates</code> to include your function. They must return html.</div>