以前一個專案框架是.NET 3.5版本的,經過修改、調整為.NET 4.5版本后,現有一個前臺表單驗證JS方法在除錯時出現彈窗提示的如下問題:
錯誤: 無法獲取未定義或 null 參考的屬性“value”。
<script type="text/javascript">
function checkmail() {
var txtmail = document.getElementById("txtmail");
var txtmailTips = document.getElementById("txtmailTips");
if (txtmail.value != "") {
var isreg = txtmail.value.match(/^\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}$/);
if (isreg == null) {
txtmailTips.innerText = '請輸入正確的郵箱地址';
return false;
}
else {
txtmailTips.innerText = '';
return true;
}
}
else {
txtmailTips.innerText = '';
return true;
}
}
</script>
應該如何作修改?
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/278711.html
標籤:ASP.NET
