<TextBox Name="txtProductCode"> <TextBox.Text> <Binding Path="ProductCode"> <Binding.ValidationRules> <jas:RegexValidationRule RegexText="^[A-Za-z]*$" ErrorMessage="Enter only character" RegexOptions="IgnoreCase" /> </Binding.ValidationRules> </Binding> </TextBox.Text> </TextBox>
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { //allows only character if (char.IsChar(e.KeyChar) == true) { e.Handled = true; } //backspace working code if (e.KeyChar == (char)Keys.Back) { e.Handled = false; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)