.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Javascript >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Validate Postal code in Javascript

Posted By:Athira Sreejith       Posted Date: February 23, 2009    Points: 10    Category: Javascript    URL: http://www.dotnetspark.com  
 

Hi..

function valIntegerPostalCode(obj)

{

var i,strVal,blnChange;

blnChange = false

strVal="";

for(i=0;i<(obj.value).length;i++)

 {

switch(obj.value.charAt(i))

 {

case "a":

 case "b":

 case "c":

 case "d":

case "e":

 case "f":

 case "g":

case "h":

case "i":

 case "j":

 case "k":

 case "l":

 case "m":

 case "n":

case "o":

 case "p":

case "q":

case "r":

 case "s":

 case "t":

case "u":

case "v":

 case "w":

 case "x":

case "y":

case "z":

case "A":

case "B":

 case "C":

case "D":

case "E":

case "F":

case "G":

case "H":

case "I":

case "J":

case "K":

case "L":

case "M":

case "N":

case "O":

case "P":

case "Q":

case "R":

case "S":

case "T":

 case "U":

case "V":

 case "W":

 case "X":

case "Y":

 case "Z":

case " ":

 case "0":

case "1":

case "2":

case "3":

 case "4":

case "5":

case "6":

case "7":

case "8":

case "-":

case "9":

strVal=strVal+obj.value.charAt(i);

 break;

default :

blnChange = true;

break;

}

}

if (blnChange)

{

obj.value=strVal;

 }

}


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend