Validations

Dec 1 2009 10:08 AM
I need to validate the fields of my textBox ... In WPF ... Someone could give me a code that works in the KeyDown event ... Or enter special characters not allowed ... I have these two codes:

1 this I agree but also allows ALT numbers and Shipf ... Need only numbers or only letters ...
KeyDown
if (e.key> = Key.D0 & & e.key <= Key.D9 | | e.key> = Key.NumPad0 & & e.key <= Key.NumPad9 | | == e.key Key.Decimal)
                
e.Handled = false;
            
else
                
e.Handled = true;


And this helps us letters and do not know how to modify it to only numbers

Event: KeyDown

Accepted String = "QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm" + Convert.ToChar (8);
            
if (Aceptados.Contains ( "" + e.key)) e.Handled = false; else e.Handled = true;

Someone could help

Answers (2)