.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 integer with special character "-" in Javascript

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

Validate integer with special character '-' in Javascript

function valIntegerwithMinus(obj)
{

var i,strVal,blnChange; blnChange = false strVal=""; for(i=0;i<(obj.value).length;i++)
{

switch(obj.value.charAt(i))

{

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