Question: Maximum of 5 characters (0.000 < courier weight <=5.000 with max of 3 digits after decimal point) Values can be between 0 and 5. Excluding 0 and including 5.
My codes:
function checkWeightOfParcel(weightOfParcel) {
var regex=/^[0-5]+\.[0-9]$/;
if(regex.test(weightOfParcel)) {
alert('correct!!!')
return true;
}
else {
alert('wrong regex!')
return false;
}
}
*my code only can validate range 0.000 to 5.999, it is wrong. How to remove 0.999 behind to set the max value is 5.000 Any website or forum to learn javascript regex? i'm new to it, thanks for help.