Hi
I am using some code to validate uk postcode. I was wondering how I could make this work with AJAX so that the check is carried out on entry. Here is what I have so far:
<form name="postcodeform" method="post">
<input type="postcode" /> Postcode<br />
</form>
function IsPostcode($postcode)
{
$postcode = strtoupper(str_replace(' ','',$postcode));
if(preg_match("/^[A-Z]{1,2}[0-9]{2,3}[A-Z]{2}$/",$postcode) || preg_match("/^[A-Z]{1,2}[0-9]{1}[A-Z]{1}[0-9]{1}[A-Z]{2}$/",$postcode) || preg_match("/^GIR0[A-Z]{2}$/",$postcode))
return true;
else
return false;
}
if (IsPostcode($postcode))
print "Valid Post Code";
else
print "Invalid Post Code";