1👍
Your function works fine. I suggest reversing the returning value like this:
decimal: function (val/*,rule*/){
if(!val){
return true;
}
return !/^[0-9]{1,6}(?:[,.][0-9]{0,5})?$/.test(val);
}
1👍
This regex works to ensure the user has entered a decimal value (upto 2 points (eg.785747.12))..
\d+(\.\d{1,2})?
I got this from
Simple regular expression for a decimal with a precision of 2
I hope this helps.
Source:stackexchange.com