问题
i have a form in wich i have several input... one of them should be a number input type.
i use this code to get only numeric input in a input type.
<script type="text/javascript">
function isNumberKey(evt){
var charCode = (evt.which) ? evt.which : event.keyCode
if ((charCode > 31) && (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>
but i need another features that i still not able to "create"...
i have an input type (example : ) and onkeyup event i call this function (isNumberKey - allowing only numeric input). in case the number wrote is composed by 4 or more numbers i'd like to return (on the same input) the string with the dot notation every 3 number... ex. 900->900 but 1234 -> 1.234 or 15000 -> 15.000.
回答1:
This might be the answer of your question to make the input strictly numeric and allow .(dot)
with it.
Make your show the number insert with a dot every 3 number, like this : 100000 -> 100.000. how?
part of question clear
UPDATE
Though not a perfect solution try this fiddle
Reference
来源:https://stackoverflow.com/questions/21984248/working-with-numeric-input-field-in-js