Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 216
Location: Boston, Ma
Trades: 0
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
The_Anomaly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-22-2005, 11:22 PM
Enigmatic's Avatar
Registered User

Posts: 86
Location: No Fixed Abode
Trades: 0
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: 216
Location: Boston, Ma
Trades: 0
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.
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Old 07-23-2005, 05:36 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
That'll be this thread then.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
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: 216
Location: Boston, Ma
Trades: 0
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");
}

??
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Old 07-24-2005, 08:16 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Code:
If (isZipCode(value)) ...
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?

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: 216
Location: Boston, Ma
Trades: 0
still confused .... do you make another javascript function that tests to see if the regular expression passed?
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Old 07-24-2005, 08:40 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
No, that function will return true or false depending on the outcome of the test
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
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: 216
Location: Boston, Ma
Trades: 0
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
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Old 07-24-2005, 09:57 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
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: 216
Location: Boston, Ma
Trades: 0
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
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to ZIP Validator`
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.32347 seconds with 12 queries