Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

regex validate money

// Requires a decimal and commas
^$?(([1-9]d{0,2}(,d{3})*)|0)?.d{1,2}$

// Allows a decimal, requires commas
(?=.*d)^$?(([1-9]d{0,2}(,d{3})*)|0)?(.d{1,2})?$

// Decimal and commas optional
(?=.*?d)^$?(([1-9]d{0,2}(,d{3})*)|d+)?(.d{1,2})?$

// Decimals required, commas optional
^$?(([1-9]d{0,2}(,d{3})*)|0)?.d{1,2}$

// *Requires/allows X here also implies "used correctly"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #regex #validate #money
ADD COMMENT
Topic
Name
4+6 =