可能重复:
在 Javascript 中验证电子邮件地址?
当服务器端无法验证时,如何使用 javascript 在客户端验证电子邮件?据我了解,Javascript 可以关闭,那么如何实现并阻止我收到 PCI 警告?
$(document).ready(function() {
var clearMePrevious = "";
// clear input on focus
$("#email").focus(function() {
if($(this).val()==$(this).attr("title")) {
clearMePrevious = $(this).val();
$(this).val("");
}
});
// if field is empty afterward, add text again
$("#email").blur(function() {
if($(this).val()=="") {
$(this).val(clearMePrevious);
}
});
$('#submitemail').click(function() {
app.ajax.load({
reqName : 'emailSubmit',
url: '$httpUrl('Bronto-OptIn')$?email=' + $('#email').val(),
selector : '#emailbox',
callback: function(responseText, textStatus) { }
});
return false;
});
});
<form id="emailsignup_form" name="emailsignup_form" method="post" action="$httpUrl('Bronto-OptIn', 'fid', 'information')$">
<div class="fl"><input class="email-signup-input" type="text" title="Enter Your Email Address" value="Enter Your Email Address" name="email" id="email" /></div>
<div class="fl"><button class="email-signup-btn" value="Submit" name="submitemail" id="submitemail">Submit</button></div>
<div class="clear"> </div>