xforms-onvalidate |
This event is fired after the value of the control is successfully validated against the available XSD information.
It is a custom-script validation, using which you can perform your own validation. This enables you to perform additional business validations on the entered value of the business object(s), which could not be defined in the XSD.
Syntax
DesignTime |
This is a design-time property and can be set through the property sheet of the control. |
Event Information
To invoke |
Make a change to the value of the controls and shift the focus to other controls. |
Default Action |
Initiates any action associated with this event. |
Named Script |
xforms_onvalidate |
Event Object Properties
Property |
Description |
---|---|
errorMessage |
Contains an error message that is displayed in case of custom validation error. If not specified, no error message is displayed and the field is highlighted to indicate the error. |
oFeedbackObject |
Optional. A JavaScript object that enables the notification description as a hyperlink. Clicking the description opens the detailed message separately. This object comprises the following properties:
|
srcElement |
Reference to the control whose value is validated |
valid |
Boolean that denotes whether the entered value is valid or not. If the value is not valid, you can set this attribute to false.
|
An event handler can access the event object and its properties through the eventObject available as a parameter on the handler.
Remarks
The onvalidate event is used to do any business validations that are not part or possible through standard XSD. This event will not be fired if the value entered is not valid as per the validation defined in standard XSD.
Example
The following sample codes demonstrate the use of this event to apply custom validations:
function onValidate(eventObject) { var value = eventObject.srcElement.value; //A custom validation if (value.indexOf("custom") >= 0) { //Cancel synchronizing the data eventObject.valid = false; alert("Data contains custom content that cannot be accepted."); } }
var value = eventObject.srcElement.value; //if value is < 1, then its invalid if (value < 1) { eventObject.valid = false; eventObject.errorMessage = "This value is invalid. Enter value >= 1"; } else { eventObject.valid = true; }
Applies to
Input, Output, Password, Textarea, Check, Radio, Select, List