Currency validation
You could use a regexp: var regex = /^\d+(?:\.\d{0,2})$/; var numStr = “123.20”; if (regex.test(numStr)) alert(“Number is valid”); If you’re not looking to be as strict with the decimal places you might find it easier to use the unary (+) operator to cast to a number to check it’s validity: var numStr = “123.20”; var … Read more