function checkPostCode(fieldno, event, postcode1, postcode2) { var charKey; var specKey; var exp; if (event.type == 'paste') { charKey = clipboardData.getData("Text"); } else if (event.type == 'keydown') { charKey = getAlfaNumPressed(event); specKey = getSpecialKeyPressed(event); if (charKey == null && specKey == null) { return false; } } if (charKey != null) { switch (fieldno) { case 1: exp = /[^0-9]/; //numeric part: accept digits only break; case 2: exp = /[^a-zA-Z]/; //alfabetic part: accept letters a-z and A-Z only break; } if (exp.test(charKey)) { return false; } } // Clear postcode fields if they were already completed if (fieldno == 1) { if (charKey != null || specKey == "Delete" || specKey == "Backspace") { if ((postcode1 != null && postcode2 != null) && (!postcode1.readOnly && !postcode2.readOnly) && (postcode1.value.length == postcode1.maxLength && postcode2.value.length == postcode2.maxLength)) { postcode1.value = ""; postcode2.value = ""; } } } return true; } //function that shifts focus when needed function nextField(obj, event, nextFld) { if (getSpecialKeyPressed(event) != null) { return; } if(obj.value.length == obj.maxLength) { document.getElementById(nextFld).focus(); } }