Regex to find out if Floating Point Field Value is negative ... how to?

Zod
Giga Guru

Sorry guys. Regex ist just not my thing.

Trying to find regex to check if a floating point field value is negative or not ... .

Should allow 0 and positive but no negative ... . 

i.e. .-0,23 .. should return false ... . Also non allowed value should return false ... 

 

Easy one for you and fast way to get a correct answer šŸ˜‰

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

Hello @Zod ,

you can try on change client script for this on floating point number field 

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

var negative = /^[0-9].*$/;
if(!negative.test(newValue)){
alert('please do not enter negative values');
g_form.setValue('field',oldValue);

}
}

please mark my answer correct if it helps you

View solution in original post

1 REPLY 1

Mohith Devatte
Tera Sage
Tera Sage

Hello @Zod ,

you can try on change client script for this on floating point number field 

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

var negative = /^[0-9].*$/;
if(!negative.test(newValue)){
alert('please do not enter negative values');
g_form.setValue('field',oldValue);

}
}

please mark my answer correct if it helps you