Situation
For example, I have a compensation leave registration form to allow users to record holiday work date and hours. Here is the form:
In the form, user input staff ID to check their current CL balance (in terms of hour), then selects the holiday work date. Next, user can input number of hours worked. By default, SharePoint allows users to input any values within a range, e.g. min 0, max 10. However, company policy restricted to record number of hours every 0.25, e.g. 0.25, 1.50, 2.75, 3.0, etc.
How to setup in InfoPath?
- Select the field to input number of hours
- Create a new rule and the type is validation
- Setup the condition and set the number of hour field does not match pattern
- Select Custom Pattern and input: [0.9]\.(0|25|5|75)
- In Screen Tip, input the error message title and description.
- Click Publish to save the changes.
Result
The error message shows when user inputs incorrectly.