如何在桌面应用程序中的电子邮件ID文本框中进行验证 [英] how to validation in email id textbox in desktop application
本文介绍了如何在桌面应用程序中的电子邮件ID文本框中进行验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
伙计们
请问家伙如何告诉我如何在桌面应用程序中的电子邮件ID文本框中进行验证?
hi guys
how to validation in email id textbox in desktop application pls guy tell me ?
推荐答案
将此代码粘贴到您的Common.Cs
------------------------------------------
Paste this code your Common.Cs
------------------------------------------
public static bool isEmail(string inputEmail)
{
if (inputEmail != "")
{
string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
@"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
@".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)
"; Regex re = 新 Regex(strRegex); 如果(re.IsMatch(inputEmail)) 返回(真); 其他 返回(错误); } 返回(真); }
"; Regex re = new Regex(strRegex); if (re.IsMatch(inputEmail)) return (true); else return (false); } return (true); }
并在Codebehind中;
and in Codebehind;
if (Common.isEmail(txtbx_Email.Text))
{
}
}
else
{
MessageBox.Show("Email not valid!", "Save", MessageBoxButton.OK, MessageBoxImage.Warning);
txtbx_Email.Focus();
return false;
}
检查所有可能的解决类似问题的方法 ^ ].
Check every possible solution to similar problems here[^].
这篇关于如何在桌面应用程序中的电子邮件ID文本框中进行验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文