Add a Phone number field. It should accept 10 digits (numeric) and can't be left alone.

gouthamsainallu
Tera Expert

Hii

        Can you please tell me how can I do this.

1 ACCEPTED SOLUTION

Hii,


        Thank you for ur reply actually in incident I didnt find the variable field so can you please tell me how can i do...by providing any screenshots.


View solution in original post

8 REPLIES 8

Hi Goutham,



Did you get your answer by my reply


preddy
Kilo Guru

Hi Goutham,



Use the below Code in Onchange Client script.



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


      if(!isLoading){  


              var val = newValue;  


              var achar = '0123456789.';


              var failmsg = 'This Field Should Allow the Numeric value.';  


                 


              var array1 = val.toLowerCase().split('');  


              for (var i=0; i < array1.length; i++){  


                      if (achar.indexOf(array1[i]) >= '0'){  


                      }  


                      else{  


                              alert(failmsg);  


                              g_form.setValue('field name', '');


                      }  


              }  


      }  


}  



Ple hit/Like if this is helpful for you


Sampath8
Giga Expert

Hi,



Please try the below OnChange client script.



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


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


return;


}


var pattern = /^[0-9]*$/;


if(!pattern.test(newValue) || (newValue.length <= 9) )


{


alert('please enter only digits and min length should be 10 ');


g_form.setValue('field_name', ''); // adjust field name accordingly if you want to blank it out.


}


}



Lrt me know if any concerns.



Regards,


Sampath.


THANKS bro its working