I have numeric textboxes in html/php/js where users will input numbers with 4 to 7 digits. However I would like the user to see spaces between every third digit.
For example,
User inputs: 8000
User sees: 8 000
User inputs 9100045
User sees: 9 100 045
How can I implement this so the input remains an int and does not get converted into a string with white space?
Thank you!
With a standard textbox, this isn’t possible.
Using javascript you could reformat the content after every key press adding spaces where necessary. However, as @Jukka K. Korpela has pointed out, this could become very confusing for the user. An alternative would be to make this change
onchangeso that the formatting only occurs when the textbox loses focus.Then server side, remove all the spaces to return an integer.