I've been testing, studying & Googling but have yet to solve this problem. I'm sure this is a very common validation routine, but I can't find the answer. The user inputs a shipping address and I need to make sure it's a street address and not a P.O. Box. Here's what I have so far:
As it stands, the alert box is always triggered regardless of the input. Can someone please shed some light?
Thanks in advance,
Gary
Code:
var stripped = document.formpmt.shipAdd.value.replace(/\./g,""); [i]//to remove periods[/i]
stripped = stripped.replace(/ /g,""); [i]//to remove spaces[/i]
stripped = stripped.toLowerCase();
if(!(stripped.match("pobox")=="null")) {
alert("We can't deliver to a P.O. Box.\n Please provide a street address for shipping.");
document.formpmt.shipAdd.focus();
return false;
}
Thanks in advance,
Gary