
关于js的onblur事件
<scriptlanguage="javascript"charset="utf-8">functioncheckUser(){varuser=document.all....
<script language="javascript" charset="utf-8"> function checkUser(){ var user = document.all.user.value.trim(); ///document.write(user); if(user.length<=6 || user==""){ document.all.userMsg.innerHTML = "用户名需要大于6位"; return false; } } function checkPwd(){ var pwd = document.all.pwd.value.trim(); if(pwd.length<=6 || pwd==""){ document.all.pwdMsg.innerHTML = "1111"; return false; } } </script> </head> <body> <form> <table> <tr><td>user:</td><td><input type="text" name="user" onblur="checkUser()"/> <span id="userMsg" class="message"></span> </td></tr> <tr><td>pwd:</td><td><input type="password" name="pwd" onblur="checkPwd()"/> <span id="pwdMsg" class="message"></span> </td></tr> </table> </form> 上面的事件在chrome中可以发生,但在ie和firefox上没反应,怎样才能在ie或者ff上发生
展开
1个回答
展开全部
把trim()改成replace(/\s/g, '')吧,估计是这个原因
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询