Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Text field that allows 10 digit numbers only without repetitive digits

Abhishek Barik
Tera Contributor

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.

find_real_file.png

Thanks in advance,

Abhishek

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

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');
    }

}

View solution in original post

6 REPLIES 6

Hitoshi Ozawa
Giga Sage
Giga Sage

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');
    }

}

Thanks for the help 🙂