Form Validation Toolkit

Custom Error Attachment Example

Outside of plain form validation based on the input attributes supplied to an input, sometimes a custom error may need to be attached. As an example, for the email field, we may need to check the database and find if the email already exists in the system, and in that case show a custom error, and remove it if the problem is resolved.

$('element').attachCustomError('Error_message'); to attach, and
$('element').detachCustomError(); to detach.

Errors that are custom attached are not auto removed by the validation script. Remember to always detach custom errors once the user corrects the problem.