I received my vehicle registration renewal last week from the Maryland Vehicle Administration. I’m not here to complain about the absurd price ($180? Seriously!)… or standing in line for hours only to be told I need to fill out another form… At the top of my renewal notice it states clearly: “New Option - RENEW ONLINE at WWW.MARYLANDMVA.COM”
First of all, there’s nothing new about MarylandMVA.com’s registration renewal. I’ve been using it for years. The look and feel is ancient, but it gets the job done. What I came across today really drove me nuts.
The first step of the renewal process asks you to input your 8 digit vehicle registration number. I get 4 digits in and accidentally mistype. I hit the backspace key, nothing happens. I hit another number… it gets added to my input. Backspace, nothing happens.
Knowing a little about web applications I decided to dig in to see what was going on. The developers of this page wrote a validation function for the registration input:
function validateTitle(field, e) {
var strCheck = '0123456789ABCDEFGHIJKLMNOPQRSTUVWZXYZabcdefghijklmnopqrstuvwxyz';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true; // Enter
key = String.fromCharCode(whichCode); // Get key value from key code
//alert(strCheck.indexOf(key));
if (strCheck.indexOf(key) == -1) return false; // Not a valid key
}
This function is called each time you press a key on the keyboard while typing in your registration number. It’s a common approach to form validation. The basics are: you hit a key, if it’s the Enter Key, a number or a letter, the character is permitted to be added to the form input. Anything else, the keystroke is denied.
To be fair, there was a warning on the main page that recommended using Internet Explorer. I tried this form in Internet Explorer and the backspace key behaves correctly. My immediate thought was “What about Mac users?” To my surprise, Safari also allows you to backspace without any problem!
The code above should specifically reject any key other than enter, a number, or A-Z. It appears that Safari’s engine Webkit was changed in 2007 to match Internet Explorer — the Backspace key does not trigger a “keypress” event. Firefox does fire a keypress for the backspace key and will therefore prevent you from correcting your mistake on the MVA form.
AFAIK, there’s nothing in the HTML spec that states whether a backspace (or arrow key, etc) should fire the onkeypress event. Should Firefox also try to “closely match Internet Explorer” with this behavior? Or should sites like the MarylandMVA be encouraged to update their sites to support modern/common browsers?






