- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2019 07:49 AM
I'm not too good with Regex. Does anyone know how I could format it so that a phone number field will accept only numbers, parentheses, and minus signs? Currently it's set up as /^\d+$/ and the field only accepts numbers.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2019 04:28 AM
Hello ,
For validation you have to create on change client script on mobile number field
Attaching screen shot for the same
******************code snippet********************
function onChange(control, oldValue, newValue, isLoading) {
if(isLoading || newValue == ''){
return;
}
// Allows formats of (999) 999-9999, 999-999-9999, and 9999999999
var pattern = /^[(]?(\d{3})[)]?[-|\s]?(\d{3})[-|\s]?(\d{4})$/;
if(!pattern.test(newValue)){
alert('Phone enter a valid phone number');
g_form.setValue('u_mobile_number', '');
}
}
**************************************************
Thank you,
PLEASE mark my ANSWER as CORRECT if it served your purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2019 04:28 AM
Hello ,
For validation you have to create on change client script on mobile number field
Attaching screen shot for the same
******************code snippet********************
function onChange(control, oldValue, newValue, isLoading) {
if(isLoading || newValue == ''){
return;
}
// Allows formats of (999) 999-9999, 999-999-9999, and 9999999999
var pattern = /^[(]?(\d{3})[)]?[-|\s]?(\d{3})[-|\s]?(\d{4})$/;
if(!pattern.test(newValue)){
alert('Phone enter a valid phone number');
g_form.setValue('u_mobile_number', '');
}
}
**************************************************
Thank you,
PLEASE mark my ANSWER as CORRECT if it served your purpose.