I have a input text box to take in an amount of money. I would like two things.
First, validate to not allow things like this
1,23.00
1,123.45.67
But these would be OK:
123456.00
123,456.00
123,456
Secondly, if 123456
is entered, I would like it to change to 123,456.00
once the user clicks out of the box.
The second part is what I'm unsure about, if there is something that did both though, that would be great.
1) Google for some nice plugin, you will find many validation scripts on the web.
2) You can use the blur
or change
event for that. Add an event listener for them, which sets the appropriate format to the input value.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.