下面是我的驗證腳本。爲什麼在輸入電子郵件時不顯示微型紅色X圖像,但不正確?我卡住了......請幫忙!html javascript email image
<form name="validation" onSubmit="return checkbae()">
<input type="text" size=18 onkeyup="return checkbae()" name="email">
<span id="email" class="email"></span>
<input type="submit" value="Submit">
</form>
<script language="JavaScript1.2">
function checkemail() {
var messageg = document.getElementById('email');
var str = document.validation.email.value
var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z] {2})?)$/i
if (filter.test(str))
testresults = true
else {
messageg.style.color = red;
messageg.innerHTML = "\u2718"
testresults = false
}
return (testresults)
}
function checkbae() {
if (document.layers || document.getElementById || document.all)
return checkemail()
else
return true
}
</script>
創建的jsfiddle此代碼:http://jsfiddle.net/p5Fha/ –
請格式化你的代碼,停止使用大膽而清楚地說明你的問題。 –
我沒有看到你已經在你的js文件中聲明瞭testresults。 – dev