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
} |