Class \Prado\Web\UI\WebControls\TCustomValidator
TCustomValidator performs user-defined validation (either server-side or client-side or both) on an input component.
To create a server-side validation function, provide a handler for the \Prado\Web\UI\WebControls\onServerValidate event that performs the validation. The data string of the input control to validate can be accessed by \Prado\Web\UI\WebControls\TServerValidateEventParameter::getValue of the event parameter. The result of the validation should be stored in the \Prado\Web\UI\WebControls\TServerValidateEventParameter::getIsValid property of the event parameter.
To create a client-side validation function, add the client-side validation javascript function to the page template. The function should have the following signature:
<script><!--
function ValidationFunctionName(sender, parameter)
{
// if(parameter == ...)
// return true;
// else
// return false;
}
--></script>
Use the \Prado\Web\UI\WebControls\setClientValidationFunction property to specify the name of the client-side validation script function associated with the TCustomValidator.
Class hierarchy
- \Prado\Web\UI\WebControls\TCustomValidator
- \Prado\Web\UI\WebControls\TBaseValidator implements IValidator
- \Prado\Web\UI\WebControls\TLabel implements IDataRenderer
- \Prado\Web\UI\WebControls\TWebControl implements IStyleable
- \Prado\Web\UI\TControl implements IRenderable, IBindable
- \Prado\TApplicationComponent
- \Prado\TComponent
Since: 3.0
public
|
evaluateIsValid() : bool
This method overrides the parent's implementation.
The validation succeeds if onServerValidate returns true. |
public
|
|
public
|
|
public
|
onServerValidate(string $value) : bool
This method is invoked when the server side validation happens.
It will raise the OnServerValidate event. The method also allows derived classes to handle the event without attaching a delegate. Note The derived classes should call parent implementation to ensure the OnServerValidate event is raised. |
public
|
setClientValidationFunction(string $value) : mixed
Sets the name of the custom client-side script function used for validation.
|
protected
|
getClientClassName() : string
Gets the name of the javascript class responsible for performing validation for this control.
This method overrides the parent implementation. |
protected
|
getClientScriptOptions() : array<string|int, mixed>
Returns an array of javascript validator options.
|
protected
|
registerClientScriptValidator() : mixed
Only register the client-side validator if
{@see setClientValidationFunction ClientValidationFunction} is set.
|