1
相呼應的HTML頁面信息,我有以下腳本打印或從JavaScript
function validateEmailp() {
var messagemail = document.getElementById('emailerrorz').innerText;
var two = document.getElementById('email').value;
var first = two.split("@")[1];
var badEmails = ["gmail.com", "yahoo.com"]
if (badEmails.indexOf(first) != -1) {
document.getElementById("email").value = ""; //this works
messagemail = 'We do not accept free e-mails'; //this doesn't
return false;
}
return true;
}
和HTML
<td>{EMAILFIELD}<span id="emailerrorz"></span></td>
和{EMAILFIELD}在PHP
<input id="email" class="txt" type="text" name="email" size="25" value="" maxlength="255" onblur="validateEmailp()"></input>
但它不對於我在打印跨度id中的錯誤時不起作用。它只適用於從那裏重置值。