How to allow integers & decimal numbers in string field

Rajesh Mushke
Mega Sage
Mega Sage

Hi team,

How to allow integers & decimal numbers in string field and avoiding alphabets



Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
1 ACCEPTED SOLUTION

This this instead. The RegEx in the other example is incorrect.



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


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


                  return;


        }



        var regexp = /^[\d\.]+$/;



        if(!regexp.test(newValue)) {


                  alert('Only numbers and dot allowed');


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


        }    


}


View solution in original post

11 REPLIES 11

You can enter them, but as soon as you go to another field, the onChange script triggers and does the evaluation, throwing an error.


Rajesh Mushke
Mega Sage
Mega Sage

No, i have updated record as well.




Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

This this instead. The RegEx in the other example is incorrect.



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


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


                  return;


        }



        var regexp = /^[\d\.]+$/;



        if(!regexp.test(newValue)) {


                  alert('Only numbers and dot allowed');


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


        }    


}


Hi Chuck,

 

 Thank you for the solution. I've used it and it's been working well. Quick follow up..

 

How would I get it to allow negative integers. At the moment this rule is blocking me from entering a number like -20? The negative symbol seems to be blocked. Is there a way to add an exception.

 

Thank you

Hi, Chuck.

May I know which table to use? Thank you.