我有一个文本框,用户应该只输入字母数字字符,并且应该允许非空格键按下,如退格键,箭头键等.此外,它还适用于所有主流浏览器(如Mozilla Firefox).
我尝试过几个例子,只允许我输入字母数字字符,但退格不适用于Mozilla Firefox中的以下示例.
$('input').bind('keypress', function (event) {
var regex = new RegExp("^[a-zA-Z0-9]+$");
var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
if (!regex.test(key)) {
event.preventDefault();
return false;
}
});
Run Code Online (Sandbox Code Playgroud) 我在用 using System.Net.Mail;
并按照以下代码发送邮件
MailMessage message = new MailMessage();
SmtpClient client = new SmtpClient();
// Set the sender's address
message.From = new MailAddress("fromAddress");
// Allow multiple "To" addresses to be separated by a semi-colon
if (toAddress.Trim().Length > 0)
{
foreach (string addr in toAddress.Split(';'))
{
message.To.Add(new MailAddress(addr));
}
}
// Allow multiple "Cc" addresses to be separated by a semi-colon
if (ccAddress.Trim().Length > 0)
{
foreach (string addr in ccAddress.Split(';'))
{
message.CC.Add(new MailAddress(addr));
}
}
// Set the subject and …Run Code Online (Sandbox Code Playgroud)