HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 27th, 2000, 08:39 AM
drbullpen drbullpen is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 3 drbullpen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi all,

Rookie here wondering if anyone could help me on my last day of work. (Fri) I have to turn this code over to someone else and it does work exactly right.
Here is the problem:
Validate Zip works great, checks for proper length as well as allowing only numbers to be entered in.
SSN_check has the same check that won't allow you to enter characters, but it doesn't work. Exactly the same code here, but one works and one won't. Did I call it wrong? Thanks for any suggestions.

function SSN_check(field, len){
var valid2 = "0123456789";
var hyphencount2= 0;

if (field.length !=len) {
alert ("Your Social Security Number entry should be 9 digits.");
return;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (valid2.indexOf(temp) == "-1") {
alert("Invalid characters in the Soc. Sec. Number. Please try again.");
return false;
}
return true;
}}
// end -->

<!-- This function works perfectly.

function validateZIP(field) {
var valid = "0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=9 && field.length!=10) {
alert("Please enter your 5 digit or 5 digit+4 zip code.");
return false;

}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code. Please try again.");
return false;
}
if ((field.length ==9) | | (field.length == 10)){
if ((hyphencount != 1) && (field.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'. Please try again.");
return false;
}}
}
return true;
}
// end -->

BODY...

Soc. Sec. Number: <input type= "text" name ="SSNum1" onKeyUp="return autoTab(this, 3, event);" size="4" maxlength="3" value="" onchange = "SSN_check(SSNum1.value,3)">-<input type= "text" name ="SSNum2" onKeyUp="return autoTab(this, 2, event);" size="3" maxlength="2" value="" onchange = "SSN_check(SSNum2.value,2)">-<input type= "text" name ="SSNum3" onKeyUp="return autoTab(this, 4, event);" size="5" maxlength="4" value = "" onchange = "SSN_check(SSNum3.value,4)" onFocus="nextfield ='Last_name';">

Zip:<input type= "text" name ="Zip" size=10 maxlength=10 value = "" onchange="validateZIP(Zip.value)" onFocus="nextfield ='Phone_a';">

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Validate Zip vs Validate Soc Sec


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway