How to add your own validations

If the validations provided by Simfatic Forms does not meet your need, you can add your own custom validation function.

The custom validation function need to be in JavaScript and runs only on the client side.

 

1348652662_001_45For more information on how to add custom server side validation, Please see DoValidate() in Extension Modules

 

 

Steps for adding a custom validation function

You can add the custom validation function in the 'Input Validations' page.

1. Click the 'Validation Options' Link

Clicking the validation options link displays the validation options page on the right side.

 

2. Check 'Custom validation function'

There is a check box 'Custom validation function'. Enable it.

 

3. Press the button 'Edit Custom Validation function'

Pressing the 'Edit Custom Validation function' button opens an editor where you can provide the JavaScript code for the validation.

 

4. Provide the custom validation code

Enter your validation code. If the validation fails, it should return an object containing the error message and the element object to which the error belongs to.

 

Example:

if(formobj.elements['Name'].value == 'Bob')
{
   return 
      ({ 
      elementobj:formobj.elements['Name'], 
      message:'Bob, you cannot submit this form!' 
      }); 
}

return true;

 

noteMake sure you return  true if there is no error.

 

See Also:

'Add Input Validations' page