How to apply regex for getting only numeric values?

Supriya P
Tera Contributor

Hi,

I have a requirement, on "Change Request" there is field Effort Estimation "Type : String". In that field only numeric value should be filled eg: 23.55, 345, 56. For that I have written a onChange client script. Values like ASdsf233 and asd.345 are cleared But it is taking value "123Asfdg" ,"456.fgj" How to clear values like 65768Asdgf.

Client script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

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


if (!regexp.test(newValue))
{
alert('It should be numeric fractional entry only');


g_form.setValue('u_effort', '');
}
}