- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 11:16 PM
Hi Team,
We have a requirement to have a text field variable that doesn't allow more than 10 digits and also no repetitive numbers. Request you to please help in providing the client script for this.
Thanks in advance,
Abhishek
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 11:57 PM
Hi,
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var reg = /^(?:(.)(?!\1{9}))\d{9}$/;
var ans = g_form.getValue('time_field'); //replace time_field with variable/field name
if (!reg.test(ans)) {
alert('Please enter valid non-repititive digits & 10 digits');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 11:35 PM
Try something as below
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var reg = /^(?!.*(.).*\1)\d{10}$/;
var ans = g_form.getValue('time_field'); //replace time_field with variable/field name
if (!reg.test(ans)) {
alert('Please enter valid non-repititive digits & 10 digits');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 11:47 PM
Hi
Thanks for the script, but the regex is not allowing numbers like "9848129660". My requirement is like not allowing numbers like "1111111111" 10 same digits shouldn't be repetitive if you see my screenshot example.
Could you please provide the updated script ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 12:04 AM
Not sure but your question was
Text field that allows 10 digit numbers only without repetitive digits.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 11:54 PM
If it's 10 same digits,
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var reg = /^(?:(.)(?!\1{9}))+$/;
var ans = g_form.getValue('time_field'); //replace time_field with variable/field name
if (!reg.test(ans)) {
alert('Please enter valid non-repititive digits & 10 digits');
}
}