Why won\'t my input resize when I change the type to type=\"number\"
but it works with type=\"text\"
?
EXAMPLE
Email: &l
Use an on onkeypress event. Example for a zip code box. It allows a maximum of 5 characters, and checks to make sure input is only numbers.
Nothing beats a server side validation of course, but this is a nifty way to go.
function validInput(e) {
e = (e) ? e : window.event;
a = document.getElementById('zip-code');
cPress = (e.which) ? e.which : e.keyCode;
if (cPress > 31 && (cPress < 48 || cPress > 57)) {
return false;
} else if (a.value.length >= 5) {
return false;
}
return true;
}
#zip-code {
overflow: hidden;
width: 60px;
}