dpmrakfbx820320638 2016-01-27 23:17
浏览 41
已采纳

联系表格不接受非拉丁字符[关闭]

For example, when someone put Greek characters in the NAME field on SEND the contact form returns with an error report. So, how do I edit my contact form to accept non-Latin characters in both NAME & MESSAGE fields?

 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;}<?php if (isset($_GET["r"])){if($_GET["r"]=="1")echo('swal("Your message has been sent!", " ", "success");');else echo('swal("Your message failed to send...", " ", "error");');};?>
  • 写回答

1条回答 默认 最新

  • dongxian7489 2016-01-28 00:44
    关注

    i took apart the js of your site, find and remove this line:

    else if(!contactname.match(name_exp)){swal("Invalid name..."," ","error");
    

    that will let the name be anything (but not blank that's checked else where)

    alternatively find

    name_exp=/^[A-Za-z\s]+$/
    

    and replace with

    name_exp=/^*+$/
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?