Hi,
I have an Alert box which pops up when a customer enters in "po box" in IE7 it doesn't let the user continue after entering "po box" in the field but in Firefox after Alerting it still lets the customer continue.

How can i make it so that on all browsers the customer cannot continue unless they remove "po box" from the field???

Javascript:

function validate() {
      var doc = document.create_account;
      var valstreet_address = new RegExp("[pP]{1}[.]*[oO]{1}[.]*[ ]*[bB]{1}[oO]{1}[xX]{1}");

      if (doc.street_address.value.match(valstreet_address) != null) {
         alert("No P O Box Allowed in Delivery Address.");
		 doc.street_address.focus();
	 }
     
   }
<?PHP echo"<input type=text name=street_address onblur=\"validate();\" value='$street_address'>"; ?>

PROBLEM 2:

How can i get my drop down menu to populate once the user has enter a 3 digit number in postcode which starts with an 8 only?
At the moment it populates the drop down after the 4th number is enetered but if it's a 3 digit postcode starting with 8, the user needs to manualy click the Load Suburbs button.

<?php  echo "<input name='postcode' type=text onkeyup=\"if(this.value.length>3)reload(this.form);else return false;\" value=$postcode>";  ?>

I want it to also reload only if a 3 digit number is entered which begins with 8.

Problem 2 solved:

onkeyup=\"if(((this.value.charAt(0) == 8)&&(this.value.length > 2))||(this.value.length > 3))reload(this.form);else return false;\"

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: <br />
<input type="text" name="street_address" onchange="validate(this.form.street_address.value);" size="20" />
<select name="list">
<option value="">PostCode</option>
</select>
<br />

PostCode:<br />

<input type="text" name="pn" onchange="pcode(this.form.pn.value)" size="10" />
</form>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.