API METHODS
VALIDATE
Invoke this method validate()
to begin validation on the form.
Return type: boolean
STATUS
This method status()
returns the number of validation errors on the form.
Return type: integer
FORM
This method form()
returns the form id attached to the instance.
Return type: string
CUSTOM RULE
This method customRule()
allows you to construct a single validation rule. To construct a rule, you need the rule's title, regular expression and an error message.
This method returns true on success and false on failure.
This method allows you to construct a single rule. Use the multiple rules method to construct more rules.
Return type: Boolean
Then in your form input, provide the rule title within the octvalidate attribute.
All rule titles are case-sensitive!
MORE CUSTOM RULES
This method moreCustomRules()
allows you to construct more custom rules.
To use this method, create an object that will contain the rule title as the object's property, and its value is an array containing the rule's regular expression, and error text separated by a comma.
This method returns true on success and false on failure.
Return type: Boolean
Then in your form input, provide the rule title within the octvalidate attribute.
You do not need to pass in your regular expression as a string! This is because the JavaScript engine natively recognizes regular expressions.
CALLBACK
This method allows you to provide additional functions that will be executed when validation tests are passed or when a validation test fails.
To use this method, provide your success callback and error callback as arguments to the method validateCallBack
. The success callback will execute when validation tests are passed and the error callback will execute when any validation test fails.
Return type: function
VERSION
This method returns the version of the release that you are using.
Return type: string
SHOW & HIDE SERVER-SIDE FORM ERRORS
This method allows the library to display server-side validation errors on the form.
If you must use this Library to process server-side validations, invoke the methods below instead of using the helper script attached to that release.
1. showBackendErrors
Invoke this method and pass in the error object to insert server-side validation errors into the form.
2. removeBackendErrors
Invoke this method and pass in a form id to remove any errors present in the form.
Server-side form validation is built for PHP & NodeJS. Please refer to their documentation.