Javascript-Check US Zipcode.

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
  2. <html>  
  3.    <head>  
  4.       <title>Sample Code</title>  
  5.       <script type="text/javascript">  
  6.          function CheckUSZipcode(MyZipCode)           
  7.          {           
  8.                 var CheckZipCode = /(^\d{5}$)|(^\d{5}-\d{4}$)/;           
  9.                 if(CheckZipCode.test(MyZipCode))           
  10.                 {           
  11.                       alert("Your Entered Zip Code Is Valid.");           
  12.                 }           
  13.                 else           
  14.                 {           
  15.                       alert("Your Entered Zip Code Is Not Valid.");           
  16.                 }           
  17.          }           
  18.       </script>  
  19.    </head>  
  20.    <body bgcolor=#00ff00 alink=blue vlink=blue>  
  21.       <FORM name="windowEvent">  
  22.          US Zip Code : <input type="text" name="txtuszipcode" />  
  23.          <input type="button" value="Check" name="btnUSZipCode" onClick="CheckUSZipcode(txtuszipcode.value)" />  
  24.       </FORM>  
  25.    </body>  
  26. </html>