JSP 页面用正则表达式验证email格式

 

验证email的JavaScript函数:

function validateemail()

{

         var accemail = document.getElementById("accemail");    //获取email控件对象
         if (!accemail.value == "") {
                   var reg =/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;

                   var bool = reg.test(accemail.value);
                   if (bool == false) {
                           alert("邮箱格式错误,请重新输入!");
                           accemail.focus();
                           return;
                   }
         }    

}

 

你可能感兴趣的:(正则表达式,email,jsp,javascript,function)