[thelist] js for zip code validation

Howard Cheng howcheng at ix.netcom.com
Mon Dec 9 16:59:00 CST 2002

It doesn't work because you are trying to compare a string to an array. You
need to loop through your array and compare each item to the input.

var found = false;
for (i=0; i<znum.length; i++)
     if (znum[i]==txt)
         found = true;
if (found)

At 05:24 PM 12/9/2002 +0800, todea wrote:
>Can someone help out with som js form validation. I want to validate a zip
>code entered by the user against a list of existing zip codes.
>I'm trying to do it like this with a few zip codes in an array. But this
>doesn't work.
>function validate()
>znum=new Array("10010","90534")
>if (txt == znum)
>  {
>  alert("good")
>  return true
>  }
>  {
>  alert("Error wrong zip")
>  return false
>  }
>* * Please support the community that supports you.  * *
>For unsubscribe and other options, including the Tip Harvester
>and archives of thelist go to: http://lists.evolt.org
>Workers of the Web, evolt !

Howard Cheng
howcheng at ix dot netcom dot com
AIM: bennyphoebe
ICQ: 47319315

More information about the thelist mailing list