the easiest way is to multiply the contents by 1 and then compare with 0 for + ve or -ve
try{
var n=$("#...").val() * 1;
if(n>=0){
}else{
}
}catch(e){
}
REGEX:
var n=$("#...").val()*1;
if (n.match(new RegExp(^\d*\.{0,1}\d*$))) {
} else if(n.match(new RegExp(^-\d*\.{0,1}\d*$))){
}
source
share