Regex in JavaScript for validating decimal numbers
Try the following expression: ^\d+\.\d{0,2}$ If you want the decimal places to be optional, you can use the following: ^\d+(\.\d{1,2})?$ EDIT: To test a string match in Javascript use the following snippet: var regexp = /^\d+\.\d{0,2}$/; // returns true regexp.test(‘10.5’)