4.7.9 The CustomValidator tag
Description
The « CustomValidator » validator is used to make a specific validation. In this case, a corresponding JavaScript function must be added to the control, and then its name must be specified as a value of clientvalidationfunction.
Example:
The following example shows how to create a validation defined in a JavaScript function called « fct_JS ».
| Rendering |
|
XHTML settings | <bluage:CustomValidator id="phonenumber_format" forid="txt_phonenumber" errormessage="Please check the phone number field format" clientvalidationfunction="validatePhone()"/> <bluage:Keep techno="all"><![CDATA[ <script> function validatePhone() { var phoneNumber = document.getElementById("txt_phonenumber").value; var regex = new RegExp(/^(01|02|03|04|05|06|08)[0-9]{8}/gi); var match = false; return phoneNumber=="" || regex.test(phoneNumber); } </script> ]]> </bluage:Keep> |
| Screen activity diagram |
|
| Entities Diagram |
|
| Service activity diagram | N/A |
Tag attributes: reference
| Name | CustomValidator |
| Documentation | Makes a specific validation defined by the user |
| Diagram |
|
Tag attributes description
| Attribute | Required | Description |
| Id | Y | Unique tag ID in the page |
| forid | Y | ID of the item to be validated |
| errormessage | N | error message to display in case of validation error |
| styleclass | N | Error message to display style CSS class |
| clientvalidationfunction | Y | JavaScript function name |



