Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need code in java script to limit number after point 3 number
and add .000 if you don't add point
and add 0 to make number after point equal 3
example
333.3333 prevent
333.33 333.330
333 333.000
333.3 333.300
Posted

1 solution

I am sure there is far better solution than this with regular expression but this is my solution
HTML
<input type='text' onkeypress='return this.value.indexOf(".")==-1?true:this.value.length-this.value.indexOf(".")<=3?true:false'>
 
Share this answer
 
v2

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