Spec Form Validators

jdubs edited this page Oct 23, 2016 · 2 revisions

Table of Contents

Overview

Four51 Spec Form Validators are extended validation controls for specific input requirements. Every validators can be defined to fire on one of two events: onblur, onsubmit. Controls for displaying validation errors is built into each validators. The event can be overridden and controlled separately if desired. It is recommended that you do not override onSuccess or onError unless absolutely necessary. All validators have identical options exposed. By default, when validation fails a red exclamation point image is displays with mouse over error message and the control's background property is changed to pink. On success these errors are cleared. When the action is defined as "onBlur" the error is marked next to the control, however the form is still allowed to submit.

Options:

  • action: The event that validation should occur. Two available choices: onSubmit, onBlur. The default value is onSubmit.
  • message: The error message to display when validation fails. Each individual validator has a specific message.
  • onSuccess(): Overridable function called when validation succeed. A parameter, "ctl", is passed as a reference to the control being validated.
  • onError(): Overridable function called when validation fails. A parameter, "ctl", is passed as a reference to the control being validated.
  • Example

    spec['Control'].number({ 
    	action: "onBlur",
    	message: "You must enter a number.",
    	onSuccess: function() {
    		alert('Your entry is a number!')
    	},
    	onError: function() {
    		alert('Your entry is not a number!')
    	});
    

    Validators

    1. custom
    2. date
    3. email
    4. minimum
    5. maximum
    6. number
    7. phone
    8. range
    9. regex
    10. required
    11. requiredIfIndex
    12. requiredIfValue
    13. url
    14. zipfour

    Clone this wiki locally
    You can’t perform that action at this time.
    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
    Press h to open a hovercard with more details.