hello friend,
I m given you code for all validation like address, name , price etc..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace demo
{
class Validation
{
public static void price_validation(KeyPressEventArgs e)
{
int num = e.KeyChar;
if (e.KeyChar == '.' || num == 8)
{
e.Handled = false;
}
else if (!char.IsDigit(e.KeyChar))
{
e.Handled = true;
}
}
public static void numeric_validation(KeyPressEventArgs e)
{
int num = e.KeyChar;
if (num == 8)
{
e.Handled = false;
}
else if (!char.IsDigit(e.KeyChar))
{
e.Handled = true;
}
}
public static void talepehone_validation(KeyPressEventArgs e)
{
int num = e.KeyChar;
if (e.KeyChar == ',' || e.KeyChar == ' ' || num == 8)
{
e.Handled = false;
}
else if (!char.IsDigit(e.KeyChar))
{
e.Handled = true;
}
}
public static void name_validation(KeyPressEventArgs e)
{
int num = e.KeyChar;
if (e.KeyChar == '.' || e.KeyChar == ' ' || e.KeyChar == '&' || num == 8 || char.IsDigit(e.KeyChar) || e.KeyChar == '-')
{
e.Handled = false;
}
else if (!char.IsLetter(e.KeyChar))
{
e.Handled = true;
}
}
public static void address_validation(KeyPressEventArgs e)
{
int num = e.KeyChar;
if (e.KeyChar == ',' || e.KeyChar == '-' || e.KeyChar == '/' || e.KeyChar == ' ' || num == 8 || char.IsDigit(e.KeyChar) || num == 13)
{
e.Handled = false;
}
else if (!char.IsLetter(e.KeyChar))
{
e.Handled = true;
}
}
public static void vision_validation(KeyPressEventArgs e)
{
int num = e.KeyChar;
if (e.KeyChar == ',' || e.KeyChar == '-' || e.KeyChar == '/' || e.KeyChar == ' ' ||e.KeyChar == '.' || num == 8 || char.IsDigit(e.KeyChar))
{
e.Handled = false;
}
else if (!char.IsLetter(e.KeyChar))
{
e.Handled = true;
}
}
}
}
just implement this code..
hope it would be help full for you..if not then reply me will give you other solution