Sunday 18 May 2008

Javascript Postcode formatting

function FormatPostcode()
{
var sPostcode;var objTempField;objTempField = document.getElementById('txtPostcode');
sPostcode = objTempField.value;sPostcode = sPostcode.toUpperCase().replace(' ','');

if (sPostcode.length >= 5){sPostcode=sPostcode.substr(0,sPostcode.length-3) + ' ' + sPostcode.substr(sPostcode.length-3,3);
}
objTempField.value=sPostcode;
}

No comments: