string field to contain only number and special character like $

chandan1994
Tera Contributor

Hello Team,

I have field called fee, which should contain numbers and $,could you help on this, as it should take special character like $

var regexp = /^[+]?\d*$/;
if(!regexp.test(newValue)){
alert('Please enter numeric value');
g_form.setValue('u_estimated_fees','');
}

i have above script to check for numbers only but how to check for special character

Thanks 

1 ACCEPTED SOLUTION

Pranesh072
Mega Sage
Mega Sage

Use following regex

it will check for "$12" format only 

var regexp = /^[$][0-9]+$/;
if(!regexp.test(newValue)){
alert('Please enter numeric value');
g_form.setValue('u_estimated_fees','');
}

 

if you want $12 or 12 

use this 

/^[$]?[0-9]+$/

View solution in original post

1 REPLY 1

Pranesh072
Mega Sage
Mega Sage

Use following regex

it will check for "$12" format only 

var regexp = /^[$][0-9]+$/;
if(!regexp.test(newValue)){
alert('Please enter numeric value');
g_form.setValue('u_estimated_fees','');
}

 

if you want $12 or 12 

use this 

/^[$]?[0-9]+$/