Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Need client script

User_267
Tera Contributor

For a variable (number) - it should accept only whole number ex:12 after that it need to autopopulate as ($12.00) including decimal and dollar symbol.

If alphabets or or any other apart from whole numbers are entered then it should show error.

6 REPLIES 6

Jaspal Singh
Mega Patron
Mega Patron

Hi,

Try below

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue == '') {
     return;
  }
var regexp =/^\d+$/;
  if(!regexp.test(newValue))
  {
 alert('Please enter Numbers. Only numbers are allowed');
  g_form.setValue('your_field_name',''); //replace your_field_name with field or variable name
  }
else
{
var setdollar='$';
var setdecimal='.00';
var valueenteredis=newValue;
var finalvalueis=setdollar+newValue+valueenteredis;
g_form.setValue('your_field_name',finalvalueis); //replace your_field_name with field or variable name
}
}

it is not working. Even if I am giving numbers it is showing alert(but if i enter number like 12- then it should populate as $12.00). I have attached the screen shot.

Replace

if(!regexp.test(newValue))

with

if(regexp.test(newValue))

Still it's not working