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!

Reviewing input form field.

Status
Not open for further replies.

dontpunchme

Programmer
Jul 29, 2002
20
US
I am trying to block certain zipcodes from submitting a form on my website.

So.. I basically want to validate the form... if the first three characters of the zip are 220 then I want to pop an alert box telling them that that the zip code isn't allowed.

Any ideas?

 
try a search on google for regular expression test on zip codes. there should be a few scripts out there for use that can be easiely modified to suite the pattern needed.

____________________________________________________
get the best answer to your questions by asking the best questions "General FAQ" faq333-2924
onpnt2.gif
 
this is some basic solution you could elaborate on it and come up with something more sophisticated..


<script>
function checkZip(elem){
var notAllowed=/^220\d\d$/.test(elem.value);
if(notAllowed){
alert(&quot;no can do sorry&quot;);
elem.select();
elem.focus();
}
}
</script>
<input type=&quot;text&quot; name=&quot;zipcode&quot; onBlur=&quot;checkZip(this)&quot;>

grtfercho çB^]\..
&quot;Imagination is more important than Knowledge&quot; A. Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top