Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate form data 1

Status
Not open for further replies.

dontpunchme

Programmer
Jul 29, 2002
20
US
Hi.

I have a site where I am collecting information from users. One of the fields is a street address. I would like to block users from entering in P.O. Boxes. I have an idea of how to do but don't know the code part.

Basically... I would like the script to search the field.. if it contains... P.O. Box, PO Box, Box then alert the user that P.O. Boxes aren't allowed.

Thanks.

 
Here
<script>
<!--
function val(){
var myString = frm1.txt1.value;
var inThere = myString.match(/P.?O.? Box/gi);
if (inThere) {
alert(&quot;Bad person!!!&quot;);
return false;
} else {
return true;
}
}
//-->
</script>

<form name=&quot;frm1&quot; onSubmit=&quot;return val();&quot;>
<input type=&quot;text&quot; name=&quot;txt1&quot;>
</form>

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top