want to validate that a field can only contain numbers or floating point number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2016 09:08 PM
I tried this code.
var regexp = new SNC.Regex('/^\d*\.?\d*/');
var value1 = g_form.getValue('variables.rom');
if(!regexp.match(value1))
{
alert('Only numbers and dot allowed');
g_form.setValue('variables.rom','');
}
But regexp.match(value1) always return true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2016 12:18 AM
Hi Haider,
Pelase try below:-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var regexp = /^[0-9.]*$/;
if(!regexp.test(newValue))
{
alert("Please enter only numbers");
g_form.setValue('u_urfield, '');
}
}
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.
Thanks,
Deepa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2019 07:57 AM
Hi, thank you for your answer.
It also helped me.
Kind regards,
Natasha Machado
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2016 12:50 AM
Let me know if you need any other assistance on this or mark the thread as closed to make it helpful for others in the future. You can find correct option by clicking on the below link.
want to validate that a field can only contain numbers or floating point number