How can I prevent guest users from entering '+' sign or '0' in front of country-code in the visitor phone number field during self registration?
Few SMS service providers are not looking for '+' sign or '0' or '00' in front of the international phone numbers to trigger the sms. Providing these values in front of country code during self-registration may fail to deliver the sms to recipient.
Using a simple regular expression, you can validate the entered phone number during the guest registration.
The below regular expression will help you to validate the phone number and allows to register only when the phone number is not staring with '+' or '0'.
It also performs the below validations.
- only numbers are allowed.
- first digit of the entered phone number should be 1 to 9, so '+' or '0' is not allowed.
- numbers from 0 to 9 are allowed from the second digit.
- also validates phone number length, the length of the phone number should be 9 to 14.
To add the above regex in the visitor_phone number filed, please navigate to ClearPass Guest >> Configuration >> (Pages)Guest Self-Registration >> select the self-registration page and go to Edit >> Register Page >> Form >> select the filed visitor_phone and set the Validator to " ISRegexMatch" and enter the above regex in the Validator Argument filed as shown below.
Note: Edit the Validation Error as per your requirement.
Adding the given regex will validate the phone number and prevent the guest user from registering the phone number starts with '+' or '0'.
Please find below the sample outputs for your reference.
Result when phone number starts with '+' or '0'.