- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 03:28 AM
Hi Team
I am facing a issue in Phone number field type
I want to display an Error message when the Phone number field allows special characters and spaces.
regards
Rushikesh
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 08:24 AM
Hello @Community Alums
Could you please try below script and check if this works for you
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var regex = /^[0-9]+$/; // Regular expression to allow only numbers
if (!regex.test(newValue)) {
g_form.showErrorBox('phone_number', 'Phone number should only contain numbers');
}
}
Thanks,
Amarjeet Pal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 07:11 AM
Hello Rushi Bhosale,
Could you please try onChange client script with regex and let me know if you need any help in scripting.
Thanks,
Amarjeet Pal
Please HIT Helpful if you find my article helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 07:29 AM
Hi, can you check the existing variable type and check associated script in that field. If field type is string it will allow else its a problem to enter the special characters and white spaces.
Suresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 08:24 AM
Hello @Community Alums
Could you please try below script and check if this works for you
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var regex = /^[0-9]+$/; // Regular expression to allow only numbers
if (!regex.test(newValue)) {
g_form.showErrorBox('phone_number', 'Phone number should only contain numbers');
}
}
Thanks,
Amarjeet Pal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 12:48 PM