Just edit this code to match your php code.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css">
<!--
form { margin: 2px 0 2px 0; padding: 0; }
input, select { margin-top: 2px; padding: 2px; }
-->
</style> <script type="text/javascript">
<!-- BEGIN HIDING
/* This would go for the validation of 3Digits entry and it should also start on with number 8. */
var post = /^[8]{1}?\d{2}$/;
/* This wil filter any combination regarding about this p.o. box blocking */
var pobox = /[pP]{1}?(\w)|(\.)[oO]{1}?(\w)|(\.)[Bb]{1}[0o]{1}[Xx]{1}/;
/* This goes for Solution1, just reEdit this for you php code. */
function validate(street_address)
{
if ( pobox.exec(street_address) ) {
alert('No P O Box Allowed in Delivery Address.');
myform.street_address.focus(); return false; }
else { alert('\nYour message goes here!'); }
}
/* This will go with Solution2, just reconfigure this 1 to match your php code*/
function pcode(pn)
{ if ( post.test(pn) )
{
var val = myform.pn.value;
var sel = document.getElementsByTagName('select')[0];
var newOpt = document.createElement('option');
var opttxt = document.createTextNode(val);
newOpt.appendChild(opttxt);
sel.appendChild(newOpt);
newOpt.setAttribute('value', val); window.location.reload();
}
else { alert('\nInvalid Entry!\nPlease Try Again.'); }
} /* That does it for now and i hope this 1 helps you... Enjoy coding! */
// DONE HIDING -->
</script> </head>
<body>
<form onsubmit="return false" name="myform">
City Address:
<input type="text" name="street_address" onchange="validate(this.form.street_address.value);" size="20" />
<select name="list">
<option value="">PostCode</option>
</select>
PostCode:
<input type="text" name="pn" onchange="pcode(this.form.pn.value)" size="10" />
</form>
</body>
</html>