codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  validate ZipCode with String methods  Kookmon at 04:57 on Friday, November 21, 2003
 

First let me say first time to this forum , hello all ,and thanks for any future help.

Ok here is the script. ..My zip validation is letting some things get through with alphabetic data, but not all the time..I confused :)

Also once I added this:

form1.zip.focus()
form1.zip.select()
return false

It will not let me move anywere off that field once iv typed anything into it? Now Im confused and trapped :) Iv left out the HTML to try to make it easyer to read...Thanks Much


function checkZip(){
var zip=document.form1.zip.value;
if (zip.length != 5){alert("Invalid Zip Code")
}
for(i=0;i<zip.length;i++){
if(zip.charAt(i)<0 || zip.charAt(i) >9){
alert("Invalid Zip Code")}
form1.zip.focus()
form1.zip.select()
return false
}
return true

}


<form
name="form1"
method="post"
action="mailto:blank@yahoo.com"
enctype="text/plain">

<input type="text"name="zip"size="5"onBlur="checkZip()">

</form>








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  sending of file over network
•  project on networking
•  Re: onclick thumbnail images in gridview or datalist
•  Re: C++ Beginner question
•  Re: Adding controls to the page in Page_Load event
•  Re: drop-down menu selected value
•  issue with onunlaod event in Firefox
•  Re: Stored procedure do not return recordset
•  Re: how to close w3wp.exe dialog Box programmatically ?


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2011