| Author |
how to restrict user from entering special characters in a Textbox?
|
kapil shukla
Greenhorn
Joined: Jan 10, 2010
Posts: 4
|
|
how to restrict user from entering special characters in a Textbox?
please provide javascipt code snippet
|
 |
Ashwini Kashyap
Ranch Hand
Joined: Aug 30, 2012
Posts: 61
|
|
Hi,
You can restrict user from entering special characters by calling JS function like:
function validateSpecialCharacters()
{
var spclChars = "!@#$%^&*()"; // specify special characters
var content = document.getElementById("txtfieldId").value;
for (var i = 0; i < content.length; i++)
{
if (spclChars.indexOf(content.charAt(i)) != -1)
{
alert ("Special characters are not allowed.");
document.getElementById("txtfieldId").value = "";
return false;
}
}
}
Regards,
Ashwini Kashyap
|
 |
 |
|
|
subject: how to restrict user from entering special characters in a Textbox?
|
|
|