- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

Packages: default System System.Caching System.Collections System.Data System.Data.ActiveRecord System.Data.ActiveRecord.Relations System.Data.ActiveRecord.Scaffold System.Data.ActiveReecord.Scaffold.InputBuilder System.Data.Commom.Sqlite System.Data.Common System.Data.Common.Mssql System.Data.Common.Mysql System.Data.Common.Oracle System.Data.Common.Pgsql System.Data.Common.Sqlite System.Data.DataGateway System.Data.SqlMap System.Data.SqlMap.Configuration System.Data.SqlMap.Statements System.Exceptions System.I18N System.IO System.Security System.Util System.Web System.Web.Services System.Web.UI System.Web.UI.ActiveControls System.Web.UI.WebControls System.Web.UI.WebControls.assets System.Xml Classes: IDataSource IItemDataRenderer IRepeatInfoUser TActiveFileUpload TBaseDataList TBaseValidator TBoundColumn TBulletedList TBulletedListDisplayMode TBulletedListEventParameter TBulletStyle TButton TButtonColumn TButtonColumnType TButtonType TCaptcha TCaptchaValidator TCheckBox TCheckBoxColumn TCheckBoxList TCircleHotSpot TClientScript TClientScriptLoader TClientSideValidationSummaryOptions TColorPicker TColorPickerClientSide TColorPickerMode TCompareValidator TCompleteWizardStep TConditional TContent TContentDirection TContentPlaceHolder TCustomValidator TDataBoundControl TDataGrid TDataGridColumn TDataGridColumnCollection TDataGridCommandEventParameter TDataGridItem TDataGridItemCollection TDataGridItemEventParameter TDataGridItemRenderer TDataGridPageChangedEventParameter TDataGridPager TDataGridPagerButtonType TDataGridPagerEventParameter TDataGridPagerMode TDataGridPagerPosition TDataGridPagerStyle TDataGridSortCommandEventParameter TDataList TDataListCommandEventParameter TDataListItem TDataListItemCollection TDataListItemEventParameter TDataListItemRenderer TDataRenderer TDataSourceControl TDataSourceSelectParameters TDataSourceView TDataTypeValidator TDatePicker TDatePickerClientScript TDatePickerInputMode TDatePickerMode TDatePickerPositionMode TDisplayStyle TDraggable TDropContainer TDropDownList TDropDownListColumn TEditCommandColumn TEmailAddressValidator TExpression TFileUpload TFont THiddenField THorizontalAlign THotSpot THotSpotCollection THotSpotMode THtmlArea THtmlElement THyperLink THyperLinkColumn TImage TImageButton TImageClickEventParameter TImageMap TImageMapEventParameter TInlineFrame TInlineFrameAlign TInlineFrameScrollBars TItemDataRenderer TJavascriptLogger TKeyboard TLabel TLinkButton TListBox TListControl TListControlValidator TListItem TListItemCollection TListItemType TListSelectionMode TLiteral TLiteralColumn TMarkdown TMetaTag TMetaTagCollection TMultiView TOutputCache TOutputCacheCalculateKeyEventParameter TOutputCacheCheckDependencyEventParameter TPager TPagerButtonType TPagerMode TPagerPageChangedEventParameter TPanel TPanelStyle TPlaceHolder TPolygonHotSpot TRadioButton TRadioButtonList TRangeValidationDataType TRangeValidator TRatingList TReadOnlyDataSource TReadOnlyDataSourceView TRectangleHotSpot TRegularExpressionValidator TRepeatDirection TRepeater TRepeaterCommandEventParameter TRepeaterItem TRepeaterItemCollection TRepeaterItemEventParameter TRepeaterItemRenderer TRepeatInfo TRepeatLayout TRequiredFieldValidator TSafeHtml TScrollBars TServerValidateEventParameter TSlider TSliderClientScript TSliderDirection TStatements TStyle TStyleSheet TTable TTableCaptionAlign TTableCell TTableCellCollection TTableFooterRow TTableGridLines TTableHeaderCell TTableHeaderRow TTableHeaderScope TTableItemStyle TTableRow TTableRowCollection TTableRowSection TTableStyle TTabPanel TTabView TTabViewCollection TTemplateColumn TTemplatedWizardStep TTextAlign TTextBox TTextBoxAutoCompleteType TTextBoxMode TTextHighlighter TTextHighlighterLineNumberStyle TValidationCompareOperator TValidationDataType TValidationSummary TValidationSummaryDisplayMode TValidationSummaryDisplayStyle TValidatorClientSide TValidatorDisplayStyle TVerticalAlign TView TViewCollection TWebControl TWebControlAdapter TWizard TWizardFinishNavigationTemplate TWizardNavigationButtonStyle TWizardNavigationButtonType TWizardNavigationContainer TWizardNavigationEventParameter TWizardNavigationTemplate TWizardSideBarListItemTemplate TWizardSideBarTemplate TWizardStartNavigationTemplate TWizardStep TWizardStepCollection TWizardStepNavigationTemplate TWizardStepType TXmlTransform |
Keyword
# Class TBaseValidator
    TComponent
       |
       --TApplicationComponent
          |
          --TControl
             |
             --TWebControl
                |
                --TLabel
                   |
                   --TBaseValidator
#### Direct Known Sub-classes: TRequiredFieldValidator , TCompareValidator , TRangeValidator , TRegularExpressionValidator , TCustomValidator , TDataTypeValidator , TListControlValidator , TCaptchaValidator TBaseValidator class TBaseValidator serves as the base class for validator controls. Validation is performed when a postback control, such as a TButton, a TLinkButton or a TTextBox (under AutoPostBack mode) is submitting the page and its CausesValidation property is true. You can also manually perform validation by calling TPage::validate(). The input control to be validated is specified by ControlToValidate. Validator controls always validate the associated input control on the serve side. In addition, if EnableClientScript is true, validation will also be performed on the client-side using javascript. Client-side validation will validate user input before it is sent to the server. The form data will not be submitted if any error is detected. This avoids the round-trip of information necessary for server-side validation. You can use multiple validator controls to validate a single input control, each responsible for validating against a different criteria. For example, on a user registration form, you may want to make sure the user enters a value in the username text box, and the input must consist of only word characters. You can use a TRequiredFieldValidator to ensure the input of username and a TRegularExpressionValidator to ensure the proper input. If an input control fails validation, the text specified by the ErrorMessage property is displayed in the validation control. However, if the Text property is set, it will be displayed instead. If both ErrorMessage and Text are empty, the body content of the validator will be displayed. Error display is controlled by Display property. You can also customized the client-side behaviour by adding javascript code to the subproperties of the ClientSide property. See quickstart documentation for further details. You can also place a TValidationSummary control on a page to display error messages from the validators together. In this case, only the ErrorMessage property of the validators will be displayed in the TValidationSummary control. Validators can be partitioned into validation groups by setting their ValidationGroup property. If the control causing the validation also sets its ValidationGroup property, only those validators having the same ValidationGroup value will do input validation. Note, the TPage::getIsValid property of the current TPage instance will be automatically updated by the validation process which occurs after TPage::onLoad of TPage and before the postback events. Therefore, if you use the TPage::getIsValid() property in the TPage::onLoad() method, you must first explicitly call the TPage::validate() method. Notes to Inheritors When you inherit from TBaseValidator, you must override the method evaluateIsValid. Since: 3.0 Author: Qiang Xue <qiang.xue@gmail.com>
Constants Inherited From TControl
AUTOMATIC_ID_PREFIX, CLIENT_ID_SEPARATOR, CS_CHILD_INITIALIZED, CS_CONSTRUCTED, CS_INITIALIZED, CS_LOADED, CS_PRERENDERED, CS_STATE_LOADED, ID_FORMAT, ID_SEPARATOR, IS_CHILD_CREATED, IS_CREATING_CHILD, IS_DISABLE_THEMING, IS_DISABLE_VIEWSTATE, IS_ID_SET, IS_SKIN_APPLIED, IS_STYLESHEET_APPLIED, RF_ADAPTER, RF_AUTO_BINDINGS, RF_CHILD_STATE, RF_CONTROLS, RF_CONTROLSTATE, RF_DATA_BINDINGS, RF_EVENTS, RF_NAMED_CONTROLS, RF_NAMED_CONTROLS_ID, RF_NAMED_OBJECTS, RF_SKIN_ID,
Constructor Summary
public | __construct Constructor.
Method Summary
protected void | addAttributesToRender ( THtmlWriter $writer) Adds attributes to renderer. Calls parent implementation and renders the client control scripts.
protected TValidatorClientSide | createClientSide ()
protected abstract boolean | evaluateIsValid () This is the major method for validation.
protected abstract string | getClientClassName () Gets the name of the javascript class responsible for performing validation for this control.
protected array | getClientScriptOptions () Returns an array of javascript validator options.
TValidatorClientSide | getClientSide () Gets the TValidatorClientSide that allows modification of the client- side validator events.
string | getControlCssClass ()
string | getControlToValidate ()
TValidatorDisplayStyle | getDisplay ()
boolean | getEnableClientScript ()
string | getErrorMessage ()
string | getFocusElementID () Gets the ID of the HTML element that will receive focus if validation fails and getFocusOnError is true.
boolean | getFocusOnError ()
boolean | getIsValid ()
string | getValidationGroup ()
TControl | getValidationTarget ()
protected string | getValidationValue ( TControl $control) Retrieves the property value of the control being validated.
void | onInit ( mixed $param) Registers the validator with page.
void | onPreRender ( mixed $param) Override parent implementation to update the control CSS Class before
void | onUnload ( mixed $param) Unregisters the validator from page.
void | onValidate () This event is raised right before the validator starts to perform validation.
void | onValidationError () This event is raised when the validator fails in validation.
void | onValidationSuccess () This event is raised when the validator succeeds in validation.
protected void | registerClientScriptValidator () Registers the individual validator client-side javascript code.
void | renderClientControlScript ( THtmlWriter $writer) Renders the javascript code to the end script.
void | renderContents ( THtmlWriter $writer) Renders the validator control.
void | setControlCssClass ( string $value)
void | setControlToValidate ( string $value) Sets the ID path of the input control to validate.
void | setDisplay ( TValidatorDisplayStyle $value)
void | setEnableClientScript ( boolean $value)
void | setEnabled ( boolean $value) This method overrides parent's implementation by setting setIsValid to true if disabled.
void | setErrorMessage ( string $value) Sets the text for the error message.
void | setFocusElementID ( string $value) Sets the ID of the HTML element that will receive focus if validation fails and getFocusOnError is true.
void | setFocusOnError ( boolean $value)
void | setForControl ( string $value) This method overrides the parent implementation to forbid setting ForControl.
void | setIsValid ( boolean $value) Sets the value indicating whether the validation succeeds
void | setValidationGroup ( string $value)
protected boolean | updateControlCssClass () Update the ControlToValidate component's css class depending if the ControlCssClass property is set, and whether this is valid.
boolean | validate () Validates the specified control.
Methods Inherited From TLabel
TLabel::addAttributesToRender(), TLabel::getData(), TLabel::getForControl(), TLabel::getTagName(), TLabel::getText(), TLabel::render(), TLabel::renderContents(), TLabel::setData(), TLabel::setForControl(), TLabel::setText()
Methods Inherited From TWebControl
TWebControl::addAttributesToRender(), TWebControl::clearStyle(), TWebControl::copyBaseAttributes(), TWebControl::createStyle(), TWebControl::getAccessKey(), TWebControl::getBackColor(), TWebControl::getBorderColor(), TWebControl::getBorderStyle(), TWebControl::getBorderWidth(), TWebControl::getCssClass(), TWebControl::getDisplay(), TWebControl::getFont(), TWebControl::getForeColor(), TWebControl::getHasStyle(), TWebControl::getHeight(), TWebControl::getStyle(), TWebControl::getTabIndex(), TWebControl::getTagName(), TWebControl::getToolTip(), TWebControl::getWidth(), TWebControl::render(), TWebControl::renderBeginTag(), TWebControl::renderContents(), TWebControl::renderEndTag(), TWebControl::setAccessKey(), TWebControl::setBackColor(), TWebControl::setBorderColor(), TWebControl::setBorderStyle(), TWebControl::setBorderWidth(), TWebControl::setCssClass(), TWebControl::setDisplay(), TWebControl::setForeColor(), TWebControl::setHeight(), TWebControl::setStyle(), TWebControl::setTabIndex(), TWebControl::setToolTip(), TWebControl::setWidth()
Methods Inherited From TControl
TControl::addedControl(), TControl::addParsedObject(), TControl::addToPostDataLoader(), TControl::applyStyleSheetSkin(), TControl::autoBindProperty(), TControl::autoDataBindProperties(), TControl::bindProperty(), TControl::broadcastEvent(), TControl::bubbleEvent(), TControl::clearChildState(), TControl::clearControlState(), TControl::clearNamingContainer(), TControl::clearViewState(), TControl::convertUniqueIdToClientId(), TControl::createChildControls(), TControl::createControlCollection(), TControl::dataBind(), TControl::dataBindChildren(), TControl::dataBindProperties(), TControl::ensureChildControls(), TControl::findControl(), TControl::findControlsByID(), TControl::findControlsByType(), TControl::focus(), TControl::getAdapter(), TControl::getAllowChildControls(), TControl::getAttribute(), TControl::getAttributes(), TControl::getChildControlsCreated(), TControl::getClientID(), TControl::getControls(), TControl::getControlStage(), TControl::getControlState(), TControl::getCustomData(), TControl::getEnabled(), TControl::getEnableTheming(), TControl::getEnableViewState(), TControl::getHasAdapter(), TControl::getHasAttributes(), TControl::getHasChildInitialized(), TControl::getHasControls(), TControl::getHasInitialized(), TControl::getHasLoaded(), TControl::getHasLoadedPostData(), TControl::getHasPreRendered(), TControl::getID(), TControl::getNamingContainer(), TControl::getPage(), TControl::getParent(), TControl::getRegisteredObject(), TControl::getSkinID(), TControl::getSourceTemplateControl(), TControl::getTemplateControl(), TControl::getUniqueID(), TControl::getViewState(), TControl::getVisible(), TControl::hasAttribute(), TControl::initRecursive(), TControl::isDescendentOf(), TControl::isObjectRegistered(), TControl::loadRecursive(), TControl::loadState(), TControl::loadStateRecursive(), TControl::onDataBinding(), TControl::onInit(), TControl::onLoad(), TControl::onPreRender(), TControl::onUnload(), TControl::preRenderRecursive(), TControl::raiseBubbleEvent(), TControl::registerObject(), TControl::removeAttribute(), TControl::removedControl(), TControl::render(), TControl::renderChildren(), TControl::renderControl(), TControl::saveState(), TControl::saveStateRecursive(), TControl::setAdapter(), TControl::setAttribute(), TControl::setChildControlsCreated(), TControl::setControlStage(), TControl::setControlState(), TControl::setCustomData(), TControl::setEnabled(), TControl::setEnableTheming(), TControl::setEnableViewState(), TControl::setID(), TControl::setPage(), TControl::setSkinID(), TControl::setTemplateControl(), TControl::setViewState(), TControl::setVisible(), TControl::trackViewState(), TControl::traverseChildControls(), TControl::unbindProperty(), TControl::unloadRecursive(), TControl::unregisterObject(), TControl::__get()
Methods Inherited From TApplicationComponent
TApplicationComponent::getApplication(), TApplicationComponent::getRequest(), TApplicationComponent::getResponse(), TApplicationComponent::getService(), TApplicationComponent::getSession(), TApplicationComponent::getUser(), TApplicationComponent::publishAsset(), TApplicationComponent::publishFilePath()
Methods Inherited From TComponent
TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()
Constant Summary
Constructor Details
## __construct
public __construct |
Constructor. This method sets the foreground color to red.
Method Details
## addAttributesToRender
protected void addAttributesToRender | (THtmlWriter $writer )
Adds attributes to renderer. Calls parent implementation and renders the client control scripts.
Input
THtmlWriter | $writer | the renderer
Output
Exception
## createClientSide
protected TValidatorClientSide createClientSide | ()
Output
TValidatorClientSide | javascript validator event options.
Exception
## evaluateIsValid
protected abstract boolean evaluateIsValid | ()
This is the major method for validation. Derived classes should implement this method to provide customized validation.
Output
boolean | whether the validation succeeds
Exception
## getClientClassName
protected abstract string getClientClassName | ()
Gets the name of the javascript class responsible for performing validation for this control. This method overrides the parent implementation.
Output
string | the javascript class name
Exception
## getClientScriptOptions
protected array getClientScriptOptions | ()
Returns an array of javascript validator options.
Output
array | javascript validator options.
Exception
## getClientSide
public TValidatorClientSide getClientSide | ()
Gets the TValidatorClientSide that allows modification of the client- side validator events. The client-side validator supports the following events. <tt>OnValidate</tt> -- raised before client-side validation is executed. <tt>OnValidationSuccess</tt> -- raised after client-side validation is completed and is successfull, overrides default validator error messages updates. <tt>OnValidationError</tt> -- raised after client-side validation is completed and failed, overrides default validator error message updates. You can attach custom javascript code to each of these events
Output
TValidatorClientSide | javascript validator event options.
Exception
## getControlCssClass
public string getControlCssClass | ()
Output
string | the css class that is applied to the control being validated in case the validation fails
Exception
## getControlToValidate
public string getControlToValidate | ()
Output
string | the ID path of the input control to validate
Exception
## getDisplay
public TValidatorDisplayStyle getDisplay | ()
Output
TValidatorDisplayStyle | the style of displaying the error message. Defaults to TValidatorDisplayStyle::Fixed.
Exception
## getEnableClientScript
public boolean getEnableClientScript | ()
Output
boolean | whether client-side validation is enabled.
Exception
## getErrorMessage
public string getErrorMessage | ()
Output
string | the text for the error message.
Exception
## getFocusElementID
public string getFocusElementID | ()
Gets the ID of the HTML element that will receive focus if validation fails and getFocusOnError is true. Defaults to the client ID of the ControlToValidate.
Output
string | the ID of the HTML element to receive focus
Exception
## getFocusOnError
public boolean getFocusOnError | ()
Output
boolean | whether to set focus at the validating place if the validation fails. Defaults to false.
Exception
## getIsValid
public boolean getIsValid | ()
Output
boolean | whether the validation succeeds
Exception
## getValidationGroup
public string getValidationGroup | ()
Output
string | the group which this validator belongs to
Exception
## getValidationTarget
public TControl getValidationTarget | ()
Output
TControl | control to be validated. Null if no control is found.
Exception
throws | TConfigurationException if ControlToValidate is empty or does not point to a valid control
## getValidationValue
protected string getValidationValue | (TControl $control )
Retrieves the property value of the control being validated.
Input
TControl | $control | control being validated
Output
string | property value to be validated
Exception
throws | TInvalidDataTypeException if the control to be validated does not implement IValidatable.
## onInit
public void onInit | (mixed $param )
Registers the validator with page.
Input
mixed | $param | event parameter
Output
Exception
## onPreRender
public void onPreRender | (mixed $param )
Override parent implementation to update the control CSS Class before the validated control is rendered
Input
mixed | $param |
Output
Exception
## onUnload
public void onUnload | (mixed $param )
Unregisters the validator from page.
Input
mixed | $param | event parameter
Output
Exception
## onValidate
public void onValidate | ()
This event is raised right before the validator starts to perform validation. You may use this event to change the behavior of validation. For example, you may disable the validator if certain condition is satisfied. Note, the event will NOT be raised if the validator is invisible.
Output
Exception
## onValidationError
public void onValidationError | ()
This event is raised when the validator fails in validation.
Output
Exception
## onValidationSuccess
public void onValidationSuccess | ()
This event is raised when the validator succeeds in validation.
Output
Exception
## registerClientScriptValidator
protected void registerClientScriptValidator | ()
Registers the individual validator client-side javascript code.
Output
Exception
## renderClientControlScript
public void renderClientControlScript | (THtmlWriter $writer )
Renders the javascript code to the end script. If you override this method, be sure to call the parent implementation so that the event handlers can be invoked.
Input
THtmlWriter | $writer | the renderer
Output
Exception
## renderContents
public void renderContents | (THtmlWriter $writer )
Renders the validator control.
Input
THtmlWriter | $writer | writer for the rendering purpose
Output
Exception
## setControlCssClass
public void setControlCssClass | (string $value )
Input
string | $value | the css class that is applied to the control being validated in case the validation fails
Output
Exception
## setControlToValidate
public void setControlToValidate | (string $value )
Sets the ID path of the input control to validate. The ID path is the dot-connected IDs of the controls reaching from the validator's naming container to the target control.
Input
string | $value | the ID path
Output
Exception
## setDisplay
public void setDisplay | (TValidatorDisplayStyle $value )
Input
TValidatorDisplayStyle | $value | the style of displaying the error message
Output
Exception
## setEnableClientScript
public void setEnableClientScript | (boolean $value )
Input
boolean | $value | whether client-side validation is enabled.
Output
Exception
## setEnabled
public void setEnabled | (boolean $value )
This method overrides parent's implementation by setting setIsValid to true if disabled.
Input
boolean | $value | whether the validator is enabled.
Output
Exception
## setErrorMessage
public void setErrorMessage | (string $value )
Sets the text for the error message.
Input
string | $value | the error message
Output
Exception
## setFocusElementID
public void setFocusElementID | (string $value )
Sets the ID of the HTML element that will receive focus if validation fails and getFocusOnError is true.
Input
string | $value | the ID of the HTML element to receive focus
Output
Exception
## setFocusOnError
public void setFocusOnError | (boolean $value )
Input
boolean | $value | whether to set focus at the validating place if the validation fails
Output
Exception
## setForControl
public void setForControl | (string $value )
This method overrides the parent implementation to forbid setting ForControl.
Input
string | $value | the associated control ID
Output
Exception
throws | TNotSupportedException whenever this method is called
## setIsValid
public void setIsValid | (boolean $value )
Sets the value indicating whether the validation succeeds
Input
boolean | $value | whether the validation succeeds
Output
Exception
## setValidationGroup
public void setValidationGroup | (string $value )
Input
string | $value | the group which this validator belongs to
Output
Exception
## updateControlCssClass
protected boolean updateControlCssClass | ()
Update the ControlToValidate component's css class depending if the ControlCssClass property is set, and whether this is valid.
Output
boolean | true if change, false otherwise.
Exception
## validate
public boolean validate | ()
Validates the specified control. Do not override this method. Override evaluateIsValid instead.
Output
boolean | whether the validation succeeds
Exception