Symptom
How to check and validate if entered values are only numbers for account number or phone number?
Environment
Employee Central - Personal Information
Reproducing the Issue
If we use the regular expression ^[0-9]*$, then when no value is furnished for the field then also the matches() result will become true.
Cause
matches() returns true when nothing is entered beacuse of technical limitation in RegEx. The same issue discussed here.
Rule trace:
- Retrieved 'PaymentInformationDetailV3.accountNumber'. Value: ''
- Call function 'matches' with parameters [, ^[0-9]*$]. Result: 'true'
Resolution
To overcome this behavior and address your requirement of checking if the field always contain numeric values, you can add an if condition which checks for null like below:
Alternately, you can follow format mentioned in KBA - 2421885
Keywords
regular expression, regex to check number, validate account number, validate phone number, regular expression to check spaces , KBA , LOD-SF-EC-PER-PRS , Personal Info - Config, Rules, RBP, UI , LOD-SF-EC-PER-PHN , Phone Info - Config, Rules, RBP, UI , How To