Class: FormValidator

FormValidator

new tart.FormValidator(formEl){tart.FormValidator}

Attach validator to formEl

Name Type Description
formEl Object

jQuery element for selected form.

Returns:
Type Description
tart.FormValidator .

Members

statictart.FormValidator.SpecRunner

Run jasmine spec

Methods

applyRule(el, rule){Object}

Apply rule and generate result in object literal

Name Type Description
el Object

jQuery object to rule rule object whom key is ruleName and value is rule options.

rule Object

rule to be applied to el.

Returns:
Type Description
Object result object which has .success and .item nodes.

getElementAttributeToCheck(el){string}

Find related element attribute for given input type

Name Type Description
el Object

jQuery object of element.

Returns:
Type Description
string elements value for related input type.

Get generated errors array which contains element (el) and error text(text)

Returns:
Type Description
Array errors array.

getFormElementByName(elementName){Object}

Find element with elementName in given form object

Name Type Description
elementName string

name of element which to be find in form.

Returns:
Type Description
Object jQuery object for given element.

getRuleKeyAndOptions(rule){Object}

Get rule key and rule options from rule object

Name Type Description
rule Object

rule object whom key is ruleName and value is rule options.

Returns:
Type Description
Object object which has .key and .options nodes.

getValidationRuleByKey(ruleKey){function}

Rule key for tart.Validation

Name Type Description
ruleKey string

key of rule.

Returns:
Type Description
function elements value for related input type.

Check if validation operation is successful or not by looking at this.errors array

Returns:
Type Description
boolean validation is successful or not.

Set validation rules to attached form

This:
Name Type Description
rules Object

given rules in object literal notation.

Returns:
Type Description
tart.FormValidator .

Validate given form object with given rules, if any errors occured this.errors array will be populated

Returns:
Type Description
tart.FormValidator .

validateOnSubmit(callback)

Validate form on submit

Name Type Description
callback function

callback function after submit.