首页 > CMS > 织梦DEDE > 正文

织梦自定义表单提交验证手机号邮箱等技巧

2024-07-12 09:12:07
字体:
来源:转载
供稿:网友
织梦dedecms自定义表单提交验证手机号邮箱等技巧。

先贴出js代码
 
<script>
  function check()
  {
name=document.getElementByIdx_x_x("fzrxm").value;
if(name=="")
{
alert("请输入姓名!")
return false;
}
 
    re = /^1/d{10}$/
tel=document.getElementByIdx_x_x("lxdh").value;
    if (re.test(tel)) {
      
    } else {
        alert("请输入正确的手机号!");
return false;
    }
 
    em = /^([a-zA-Z0-9_/./-])+/@(([a-zA-Z0-9/-])+/.)+([a-zA-Z0-9]{2,4})+$/;
eml=document.getElementByIdx_x_x("lxqq").value;
    if(em.test(eml)){
     
    }else{
        alert("请输入正确的邮箱!");
return false;
    }
 
 
 }
</script>


下面,在form表单提交的时候 ,加上
 
<form action="/plus/diy.php" enctype="multipart/form-data" method="post"  onsubmit="return check()">

很容易的方法,如果还不明白的朋友可以留言。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表