RadCaptcha provides the server-side CaptchaValidate event which is fired before the control is validated. This event allows you to execute server-side code on RadCaptcha validation, to cancel the default validation mechanism of the captcha control and to specify your own logic for validating the input code.
The CaptchaValidateEventArgs object of the CaptchaValidate event exposes the following properties:
-
CancelDefaultValidation—specifies whether the default validation of RadCaptcha will proceed after the event is fired.
-
IsValid—determines whether the RadCaptcha validation is successful. It should be used if CancelDefaultValidation is set to true.
This example demonstrates how to implement custom RadCaptcha validation:
-
The CancelDefaultValidation property of the event arguments object is set to true so that the default validation is not executed.
-
The IsValid property of the captcha control is set depending on the condition that should be met in order for the RadCaptcha to be validated.
- In addition to this, the border of the captcha image is changed to notify whether the validation is successful.