Open source software security

JavaScript Auto Tabbing Function

30 November -0001
This function is useful for auto tabbing through fields (for instance if you set up a set of fields for a phone number) so users don't have to tab or click through fields. Field1 is the field you're working on, len is the maximum length of the field, and field2 is next field to tab to.
function autoTab(field1, len, field2) {
	if (document.getElementById(field1).value.length == len) {
		document.getElementById(field2).focus();
		}
}

You would set up the HTML like so:
Phone Number: (<input type="text" name="area" id="area" size="3" maxlength="3" onkeyup="autoTab('area', '3', 'prefix')"/>)<input type="text" name="prefix" id="prefix" size="3" maxlength="3" onkeyup="autoTab('prefix', '3', 'suffix')"/> - <input type="text" name="suffix" id="suffix" size="4" maxlength="4"/>

Try it out:
Phone Number: () -