C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Prevent entering special characters using javascript


Posted Date: 03 Jun 2008    Resource Type: Code Snippets    Category: Javascript
Author: Kumar VeluMember Level: Diamond    
Rating: Points: 10



javascript function to prevent entering special characters

I have called one javascript function onkeydown event of textbox
that javascript function identifies the key values entering ,by using this you can prevent user entering specialcharacters and space etc.


function AllowcharNum(e)
{
var keyVal =(window.event) ? event.keyCode : e.keyCode;
if (window.event) keyVal = window.event.keyCode;


if((window.event.shiftKey))
{
if((keyVal > 48 && keyVal < 57))
{
return false;
}
else if((keyVal > 96 && keyVal < 105))
{
return false;
}
else if((keyVal == 46))
{
return false;
}
else if((keyVal == 8))
{
return false;
}
else
{
return false
}
}
else
{
if((keyVal > 48 && keyVal < 57))
{
return true;
}
else if((keyVal > 96 && keyVal < 105))
{
return true;
}
else if((keyVal == 46))
{
return true;
}
else if((keyVal == 8))
{
return true;
}
else if((keyVal == 57))
{
return true;
}
else if((keyVal == 48))
{
return true;
}
else if((keyVal > 65 && keyVal < 90))
{
return true;
}
else if(keyVal==65)
{
return true;
}
else if(keyVal==90)
{
return true;
}
else if((keyVal == 16))
{
return false;
}
else
{
return false;
}
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Javascript date validation
Previous Resource: Listing Folder Contents using Javascript
Return to Discussion Resource Index
Post New Resource
Category: Javascript


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use