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

Chuck Tomasi
Tera Patron

You can do this with an onChange client script using a regular expression.


You may find this community post helpful


INteger only field


Rajesh Mushke
Mega Sage
Mega Sage

Hi chuck,



i tried but not working




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

Can you share the client script (and screenshot of the entire record)?


Rajesh Mushke
Mega Sage
Mega Sage

okay sure, it is allowing alphabets after the two digits e.g. 1.2h




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