Reply
ZIP Validator`
Old 07-22-2005, 10:33 PM ZIP Validator`
The_Anomaly's Avatar
Extreme Talker

Posts: 201
Location: Boston, Ma
i might have posted this awhile ago but i dont remember an answer. I need a javascript zip code validator that will work onblur. I would do it myself because i dont think it should be that hard but i dont remember regular expressions at all someone wanna hammer that reg expression or a working function out for meh
__________________
Forum Admin (taking no credit for design): http://rsfreedom.com/
The_Anomaly is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-22-2005, 11:22 PM
Enigmatic's Avatar
Registered User

Posts: 86
Location: No Fixed Abode
http://javascript.internet.com/forms/val-zip-code.html
Enigmatic is offline
Reply With Quote
View Public Profile
 
Old 07-23-2005, 05:06 AM
The_Anomaly's Avatar
Extreme Talker

Posts: 201
Location: Boston, Ma
I tried that one but when it ran it asked for a zip code. i dont need to ask for a zip there's a field supplied. I removed the part that asked for a zip but then it didnt even work.
__________________
Forum Admin (taking no credit for design): http://rsfreedom.com/
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Old 07-23-2005, 05:36 AM
chrishirst's Avatar
Super Moderator

Latest Blog Post:
Am I impressed or what?
Posts: 14,899
Location: Blackpool. UK
That'll be this thread then.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-24-2005, 07:30 PM
The_Anomaly's Avatar
Extreme Talker

Posts: 201
Location: Boston, Ma
o yeah. You showed me this
Code:
function isZipCode(value) {
   var RegExp = /^\d{5}([\-]\d{4})?$/;
   return (RegExp.test(value));
}
Now if i want to use that onblur how would i go about doing this?

if(RegExp.test(value) != true)
{
alert("You input an invalid zip code");
}

??
__________________
Forum Admin (taking no credit for design): http://rsfreedom.com/
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Old 07-24-2005, 08:16 PM
chrishirst's Avatar
Super Moderator

Latest Blog Post:
Am I impressed or what?
Posts: 14,899
Location: Blackpool. UK
Code:
If (isZipCode(value)) ...
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System

Last edited by chrishirst : 07-24-2005 at 08:17 PM. Reason: missed closing [code]
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-24-2005, 08:23 PM
The_Anomaly's Avatar
Extreme Talker

Posts: 201
Location: Boston, Ma
still confused .... do you make another javascript function that tests to see if the regular expression passed?
__________________
Forum Admin (taking no credit for design): http://rsfreedom.com/
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Old 07-24-2005, 08:40 PM
chrishirst's Avatar
Super Moderator

Latest Blog Post:
Am I impressed or what?
Posts: 14,899
Location: Blackpool. UK
No, that function will return true or false depending on the outcome of the test
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-24-2005, 09:25 PM
The_Anomaly's Avatar
Extreme Talker

Posts: 201
Location: Boston, Ma
ok this is what i have and no matter what you put in it says you put a wrong zip in

Code:
function zipCheck(value) 
{
   var RegExp = /^\d{5}([\-]\d{4})?$/;
   
if(!RegExp.test(value))
{
    alert("You input an invalid zip code");
}

}
i hate javascript
__________________
Forum Admin (taking no credit for design): http://rsfreedom.com/
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Old 07-24-2005, 09:57 PM
chrishirst's Avatar
Super Moderator

Latest Blog Post:
Am I impressed or what?
Posts: 14,899
Location: Blackpool. UK
Code:
<script type="text/javascript">
function isZipCode(value) {
   var RegExp = /^\d{5}([\-]\d{4})?$/;

   if (!RegExp.test(value)) {
   alert("Error in Zip Code");
   }
}
</script>
HTML Code:
<input type="text" name="zip" value="" onBlur="isZipCode(this.value);">
works for me OK. How are you calling the function?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-24-2005, 11:19 PM
The_Anomaly's Avatar
Extreme Talker

Posts: 201
Location: Boston, Ma
BAH! that was so stupid. in the form i had onblur=zipCheck(this) not onblur=zipCheck(this.value)



thanks for bearin with me on this one
__________________
Forum Admin (taking no credit for design): http://rsfreedom.com/
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to ZIP Validator`
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15644 seconds with 12 queries