jquery valid email check
Possible Duplicate:
Validate email address in Javascript?
I am just a beginner in jquery.I have used email field in my form. The form shouldn't submit if the email field is empty. I used the following code
if(document.getElementById('emailaddress').value == ''){
alert('Enter the Email Address');
document.getElementById('emailaddress').focus();
return false;
}
How can i check the entered email is a valid one using simple jquery?
Your best bet would be to use the jquery validate plugin.
A live email validation demo can be seen here
Here is some sample code:
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js" type="text/javascript"></script>
<script>
$(function () {
$("#myForm").validate({
rules: {
emailaddress : {
required: true,
email: true
}
}
});
});
</script>
<form id="myForm">
Email address: <input type="text" name="emailaddress" id="emailaddress" class="required" >
</form>
链接地址: http://www.djcxy.com/p/16506.html
上一篇: 用正则表达式进行邮件验证
下一篇: jquery有效的电子邮件检查