InfoPath: How to restrict users to input numbers with correct format?

Situation

For example, I have a compensation leave registration form to allow users to record holiday work date and hours. Here is the form:

InfoPath - Regular Expression to validate value 0.25 0.5 0.75 - 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?

InfoPath - Regular Expression to validate value 0.25 0.5 0.75

  1. Select the field to input number of hours
  2. Create a new rule and the type is validation
  3. Setup the condition and set the number of hour field does not match pattern
  4. Select Custom Pattern and input: [0.9]\.(0|25|5|75)
  5. In Screen Tip, input the error message title and description.
  6. Click Publish to save the changes.

Result

The error message shows when user inputs incorrectly.

 

 

InfoPath - Regular Expression to validate value 0.25 0.5 0.75 - Result