Regular expression to restrict 20 characters in single line text variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2019 03:37 AM
HI All,
I need help to build regular expression to restrict enter 20 numbers & below characters in single line text.
20 Numeric and only the special characters that include: + ( ) -
Thanks in advance.!
Thanks,
Rajashekhar Mushke
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2019 05:48 AM
Hi Asifnoor
Thanks,
Rajashekhar Mushke
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2019 05:58 AM
Hi Asif,
Not working
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2019 03:29 AM
Can you tell me which case is failing? and how you are testing this code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2019 07:38 AM
Hi Asif,
Here is my client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var pattern =/^[0-9-+()]{1,20}$/;
if(!pattern.test(newValue)){
alert('Phone enter a valid Contact number');
g_form.setValue('Variable_name', '');
}
}
Thanks,
Rajashekhar Mushke
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2019 11:59 AM
Hi,
I just tried with this code on incident table and hsort_description field and it seems to be working fine. Just verify in your code, if it is entering onchange or not. If entered, then check whether its entering the if conditon or not.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
alert("test");
//Type appropriate comment here, and begin script below
var pattern =/^[0-9-+()]{1,20}$/;
if(!pattern.test(newValue)){
alert('Phone enter a valid Contact number');
g_form.setValue('short_description', '');
}
}
Mark the comment as a correct answer and also helpful once worked.