P
PJ
I've been using this function to limit a text input to numbers only with success on an old site.
function checkForInt(evt) {
var charCode = ( evt.which ) ? evt.which : event.keyCode;
return ( charCode >= 48 && charCode <= 57 );
}<input id="txt" type="text" onkeypress="return checkForInt(event)" />However, on a new site I am building, the text input not only disallows letters, it also doesn't allow tabbing to the next control, hitting return, backspace, delete, left/right arrow, etc. I obvioulsy want to allow these keys. The only difference between the two is that the new site is xhtml 1.0 transitional. Has anyone else experienced this?
Also, what is the proper syntax to wire up an event like this without typing the event attribute in the markup itself?
document.getElementById('txt').onkeypress = function(event) { return checkForInt(event); }
????
Thanks,~PJ
function checkForInt(evt) {
var charCode = ( evt.which ) ? evt.which : event.keyCode;
return ( charCode >= 48 && charCode <= 57 );
}<input id="txt" type="text" onkeypress="return checkForInt(event)" />However, on a new site I am building, the text input not only disallows letters, it also doesn't allow tabbing to the next control, hitting return, backspace, delete, left/right arrow, etc. I obvioulsy want to allow these keys. The only difference between the two is that the new site is xhtml 1.0 transitional. Has anyone else experienced this?
Also, what is the proper syntax to wire up an event like this without typing the event attribute in the markup itself?
document.getElementById('txt').onkeypress = function(event) { return checkForInt(event); }
????
Thanks,~PJ