JQuery验证邮箱

            <h3>
		    <div><a href="###" onclick="EmailToggle();return false;" class="gray2">修改</a></div>
			注册邮箱
	   </h3>
		<div id="email_display_block">
			<div class="account_right_info">
				1292722506@qq.com
			</div>
			<span class="account_title">您的注册邮箱</span>
		</div>
		<div id="email_edit_block" class="hide account_edit_block">
            <span class="account_title"> 帐户密码: </span>
            <input id="txt_change_email_password" style="width:200px;" class="tb_m" type="password" /><br />
		<span class="account_title">新注册邮箱:</span>
		<input id="txt_email" class="tb_m" style="width:200px;" type="text" />
			<div class="account_btn_wrapper">
				<input type="button" onclick="ChangeEmail();" value="保存" style="margin-left: 0;" />
				<input type="button" onclick="EmailToggle();" value="取消" style="margin-left: 3px;" />
				<br />
				<span id="tip_email" class="text_red"></span>
			</div>
function ChangeEmail() {  
var value = $("#txt_email").val(); if (value == '') {
$.messager.alert('请输入新注册邮箱地址');
return;
}
var oldEmail = $('#email_display_block div').html();
if (value == oldEmail) {
$.messager.alert('新注册邮箱地址不能与原注册邮箱地址相同');
return;
}
//邮箱验证
var regex = new RegExp('(\\w|\-)+@((\\w|\-)+\\.)+[a-z]{2,3}');

if (!regex.test(value)) {
$.messager.alert("注册邮件格式不正确");
}
var password = $('#txt_change_email_password').val();
if(password == '') {

$("#tip_email").html('请输入帐户密码');
return;
}
posted on 2016-05-21 21:31  DDLL11  阅读(106)  评论(0编辑  收藏  举报