what is the code of only accept numerics only 10 digits

Kishore Babu S
Tera Contributor

what is the code of only accept   numerics only 10 digits

if end user tries to enter the alphabets it show one message it accepts only numerics

5 REPLIES 5

Shishir Srivast
Mega Sage

Please check if this helps.



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }


var str = g_form.getValue('your_field');


var patt = /\d{10}/;


var result = patt.test(str);


if (!result) {


        g_form.setValue('your_field', '')';


        alert('Please enter value 10 digit number');


}


}