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);" />


Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  textbox validation - divya rocks  12-May-08 02:46 2:46:51 AM
      here it is.. - santhosh kapa  12-May-08 02:52 2:52:31 AM
          spaces - divya rocks  12-May-08 03:06 3:06:08 AM
              Use keycode as 32 - Sujit Patil  12-May-08 03:10 3:10:06 AM
                  Use keycode as 32 - Sudha Konchada  14-May-08 02:15 2:15:33 AM
              add space ascii - santhosh kapa  12-May-08 03:10 3:10:12 AM
      Hi go thr this - Sujit Patil  12-May-08 03:07 3:07:37 AM
      textbox validation - Masked TextBox Concept - Rakesh Vikram  12-May-08 03:13 3:13:22 AM
      re: TextBox validation - Chirag Bhavsar  12-May-08 03:24 3:24:36 AM
      Check here... - Vasanthakumar D  12-May-08 03:16 3:16:02 AM
      Simple - Rave Rasaiyah  12-May-08 05:16 5:16:37 AM
      Costom control - Rave Rasaiyah  12-May-08 05:18 5:18:23 AM
      see this - Sanjay Verma  12-May-08 05:41 5:41:03 AM
      Textbox validation - Thiru Kumaran  12-May-08 01:45 1:45:19 PM
View Posts