I am new to regular expression. I have to validate an input, such as that should be non-negative numeric value (case 1) and non-negative numeric decimal value (case 2) (i.e. 0.5, 0.2, 10.0 etc) . I have tried out like below.
[CODE=javascript]
var reg2 = /^\d*\.{0,1}\d+$/;
if(!reg2.test(s tr)) {
alert("Not valid");
}[/CODE]
1. Is this enough to check for non negative numbers ?
2. How can I check for non negative decimal values ?
[CODE=javascript]
var reg2 = /^\d*\.{0,1}\d+$/;
if(!reg2.test(s tr)) {
alert("Not valid");
}[/CODE]
1. Is this enough to check for non negative numbers ?
2. How can I check for non negative decimal values ?
Comment