Check here... |
| Vasanthakumar D replied to divya rocks at 12-May-08 03:16 |
Hi,
Using Javascript or validation control is the easiest way for character validation... you can avoid this at client side itself and postback ...
or
you need to check this at server side only which may not feasible and post back required...
use this code for characters and space key validation...
function AllowAlphabetsOnly(e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (event) keycode = event.keyCode;
else if (e) keycode = e.which;
else return true;
//keycodes allowed but not in the beginning - space
if((keycode >= 65 && keycode <= 91) || (keycode >= 97 && keycode <= 122) || (keycode == 32))
{
return true;
}
else
{
return false;
}
return true;
}
and call the above function as
<asp:TextBox ..... OnKeyPress="return AllowAlphabetsOnly(this);" /> |
|