re: TextBox validation

Chirag Bhavsar replied to divya rocks at 12-May-08 03:24

if you dont want to use javascript amd validation control then this can be done on server side on post back event.

here you can do the validation.

keypress event wont work. as this event can only handled in client side coding using javascript which you dont want.

you may use textChanged event this is you can handle on server side here you can write the logic to find the invald characters.

use

char.IsDigit(textbox.text,index) ' index is the position of the char that you want to check for.

and

char.IsWhiteSpace(textbox.text,index) ' to check for white spaces

 

if  char.IsDigit(textbox.text,index) = false and char.IsWhiteSpace(textbox.text,index) = flase then

' do appropriate action

end if

try this code:

 

foreach (char c in TextBox1.Text)
            if (char.IsDigit(c) && char.IsWhiteSpace(c))
                continue;
            else
            {
                //do something
            }

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