How to check the validation of edittext for pan card like \"ABCDE1234F\". I am confused how to check the the validation for this. Please help me guys. I will appreciate any kind
You can use Key press Event for PAN Card Validation in C#
enter code here
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
int sLength = textBox1.SelectionStart;
switch (sLength)
{
case 0:
case 1:
case 2:
case 3:
case 4:
if (char.IsLetter(e.KeyChar) || Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
break;
case 5:
case 6:
case 7:
case 8:
if (char.IsNumber(e.KeyChar) || Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
break;
case 9:
if (char.IsLetter(e.KeyChar) || Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else
{
if (Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
break;
default:
if (Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
break;
}
}