The Custom Validation is used to build your own data validation rules to make sure all the input data are structured and well managed. You can also customized the error message if the validation rule is match.
Data validation is important, for most cases , it’s a core feature. Say you want to record a customer’s IBAN for money transfers. An IBAN always has exactly 27 characters; it’s not all right if someone by mistake inputs 25 or 28 characters or puts spaces into it. You need to set the IBAN field’s length to 27 characters and request that you fill out those 27 characters, not one less, not one more!
Same goes for zip/postal codes, or tax codes. Validation rules are needed for such fields. A lot of stuff can get messed up if this kind of data is not recorded correctly, such as payments, shipments, fees. It’s a serious matter!
Phone numbers and email fields should be validated, too, because they should not accept invalid characters.
You should be able to set Date fields to accept only certain ranges of data. Such as: “you cannot input a delivery date that is before today”.
Where to set?
The custom validation function is a part of the validation settings for field controls on Approval forms or List forms. To set the custom validation, firstly select one of the field control (like Text Box, Number, Dropdown etc.) from the form designer, then open the Content > Validation block. Click the Custom Validation button to open the settings window:
How it works?
In the Custom validation pop-up window, there are 2 options to set:
Rule: Set the validation rule by adding logics with expression editor.
Error Message: Set the customize message with expression editor. This message will display under this selected filed control.
To learn how to use the expression editor, please refer: Understand Expression Editor.
Here is an example to introduce how to validate the email address and phone number with custom validation: