Click here to Skip to main content
15,915,087 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a textbox named "txtMoney"
I want to validate this textbox using javascript. And its validation criteria are as follows

* Negative number is not allowed
* All numerics. No letters
* Only two digits after decimal
* Maximum 12 digits including decimal


How can i do this.
Posted

You can use Javascript RegEx to validate for a currency input (assumption based on name of text box). A quick search of a google term to reveal that gives you;
validate-currency-amount-using-regular-expressions-in-javascript[^]
 
Share this answer
 
Using Regex
Javascript Currency Validation[^]

without Regex
Money Format[^]

BTW you may use maxlength[^] Attribute to specify the maximum length of the control.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900