如何获取此脚本(检查数据库中的电子邮件地址):
$("#engemail").keyup(function (e) {
var engemail = $(this).val();
var input=$(this);
var re = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
var is_email=re.test(input.val());
if(is_email){
$("#engemail-result").html('');
$.post('includes/pub/email.php', {'engemail':engemail}, function(data) {
console.log(engemail);
if(data == '1'){
$("#ny_button").attr("disabled", true);
$('#engemail').css('border', '3px #c0392b solid');
$("#engemail-result").html(' kan ikke godkendes?');
} else {
$("#ny_button").attr("disabled", false);
$('#engemail').css('border', '3px #2ecc71 solid');
$("#engemail-result").html(' er godkendt!');
}
});
} else {
$("#ny_button").attr("disabled", true);
$('#engemail').css('border', '3px #c0392b solid');
$("#engemail-result").html(' findes ikke i vores system?');
}
});
要在此弹出窗口中工作?
document.addEventListener("DOMContentLoaded", function () {
var trigger = document.querySelector('#js-overlay-trigger');
trigger.addEventListener('click', function(e){
e.preventDefault();
novicell.overlay.create({
'selector': trigger.getAttribute('data-element'),
'class': 'selector-overlay',
"onCreate": function() { console.log('created'); },
"onLoaded": function() { console.log('loaded'); },
"onDestroy": function() { console.log('Destroyed'); }
});
});
});
}
});
此处弹出窗口/ HTML:
<div class="overlay-content" id="js-overlay-content" style="display: none;">
<h1 class="font-weight-5">Denne popper upper</h1>
<p>Indtast din email (som du brugte, da du oprettede din konto hos os.).</p>
<form class="form-horizontal" id="sendkode" method="post" onsubmit="return doit()">
<div class="form-group">
<label class="sr-only" for="email">Email</label>
<label for="email">Din email<span id="engemail-result"> </span> </label>
<input name="engemail" type="text" class="form-control" id="engemail" placeholder="Email adresse" required autofocus>
</div>
<br>
<div class="form-group">
<button type="submit" id="ny_button" class="btn btn-primary">Send</button>
</div>
</form>
</div>
我对javascript的了解还不够强,所以希望在这里寻求帮助和建议。该脚本可以在“常规”模式弹出窗口中正常运行,有一些很好的建议:-)
答案 0 :(得分:0)
此脚本在哪里:
$("#engemail").keyup(f...
位于? 它应该在html下面,以便engemail输入标签将有足够的时间在DOM中呈现。