String Tel = Tb_tel. Text.trim ();//Contact number
if (!string. IsNullOrEmpty (Tb_tel. Text.trim ()))
{
Try
{
num = Convert.ToInt32 (TxtTEL.Text.Trim (). ToString ());
Convert.toint64 (Tb_tel. Text.trim ());
}
catch (Exception ex)
{
Aspxcallback1_save. jsproperties["cpmess" = "Input contact phone format is incorrect!" ";
Tb_tel. SelectAll ();
Tb_tel. Focus ();
Return
}
if (Tb_tel. Text.length! = 11)
{
Aspxcallback1_save. jsproperties["cpmess"] = "Contact phone length must be 11 bit, please enter correctly!" ";
Tb_tel. SelectAll ();
Tb_tel. Focus ();
Return
}
if (! System.Text.RegularExpressions.Regex.IsMatch (tel, @ "^ (0?1[358]\d{9}) | ( (0 (10|2[1-3]|[ 3-9]\D{2}))? [1-9]\d{6,7})))
{
Aspxcallback1_save. jsproperties["cpmess"] = "The contact number you entered does not exist or is illegal!" ";
Txttel.selectall ();
Tb_tel. Focus ();
Return
}
}
How to judge the legality of contact telephone in C #