Home > Web Front-end > JS Tutorial > body text

jQuery simply implements verification email format_jquery

WBOY
Release: 2016-05-16 15:50:15
Original
1301 people have browsed it

You may need to use the email verification code when submitting the form. The code is relatively simple, just to determine the email format. If there is any difficulty, it may be about the use of regular expressions. I won’t go into details here. You can check it yourself. , here is a piece of verification code that can be used, just copy and paste it.
The code example is as follows:

<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
 $("#bt").click(function(){
  if($("#email1").val()=="")
  {
   alert("邮箱不能为空");
   return false;
  }
  var email=$("#email1").val();
  if(!email.match(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/))
  {
   alert("格式不正确!请重新输入");
   $("#email1").focus();
  }
 })
})
</script>
</head>
<body>
 <form action="#">
 <input type="text" id="email1">
 <input type="button" value="提交" id="bt">
 </form>
Copy after login

The above code implements simple email verification, and it can be used after assigning and pasting the code.

The above is the entire content of this article, I hope you all like it.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template