So right now the user is able to insert a decimal value in the number field of the HTML5 input type="number". I want to prevent that, so if a user types "5.1" it will insert "51" in the textbox.
Is there any way to do this? Thanks!
So right now the user is able to insert a decimal value in the number field of the HTML5 input type="number". I want to prevent that, so if a user types "5.1" it will insert "51" in the textbox.
Is there any way to do this? Thanks!
 
    
    The definite answer is this:
function preventDot(e) {
            var key = e.charCode ? e.charCode : e.keyCode;
            if (key == 46) {
                e.preventDefault();
            }
        }
And bind it on keydown
 
    
    You can use a regular expression to find the characters that make the value a decimal value, and then delete them so that the value internally becomes an integer:
/[\.,]/
