联系表不接受希腊字符

Contact form doesn't accept Greek characters

当有人在“发送”联系表 returns 的“姓名”字段中输入希腊字符并报告错误时。 那么,如何编辑我的验证表单以在 NAME 和 MESSAGE 字段中接受希腊字符?

function validation() {
var contactname = document.forms["contactfrm"]["name"].value;
var name_exp = /^[A-Za-z\s]+$/;
if (contactname == '') {
swal("You forgot your name...", " ", "warning");
document.forms["contactfrm"]["name"].focus();
return false;
} else if (!contactname.match(name_exp)) {
swal("Invalid name...", " ", "error");
document.forms["contactfrm"]["name"].focus();
return false;
} 
var email = document.forms["contactfrm"]["email"].value; 
//var email_exp = /^[A-Za-z0-9\.-_$]+@[A-Za-z]+\.[a-z]{2,4}$/;
var email_exp = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if (email == '') {
swal("You forgot to enter your email...", " ", "warning");
document.forms["contactfrm"]["email"].focus();
return false;
} else if (!email.match(email_exp)) {
swal("Your email address is invalid...", " ", "error");
document.forms["contactfrm"]["email"].focus();
return false;
}
var message = document.forms["contactfrm"]["comments"].value;  
if (message == '') {
swal("No empty messages, please...", "warning");
document.forms["contactfrm"]["comments"].focus();
return false;
}
return true;
}

您可以通过将名称表达式更改为:

来实现此目的
name_exp=/^[A-ZA-zΑ-Ωα-ωίϊΐάέήόύϋΰώΆΈΉΌΏΎΫ\s]+$/;

并将表达式通过电子邮件发送至:

//var email_exp=/^[A-Za-z0-9\.-_$]+@[A-Za-z]+\.[a-z]{2,4}$/;
var email_exp=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;