form的onsubmit事件--表单提交前的验证最佳实现方式

来源:互联网 发布:淘宝上远程解锁可靠吗 编辑:程序博客网 时间:2024/05/16 04:38
function check(){
   var name = document.getElementById("name").value;
   if(name ==  null || name == ''){
        alert("用户名不能为空");
        return false;
   }
   return true;
}


<form name="form" action="跳转的页面" method="post"  onsubmit="return check()">
  <input type="text" id="name"/>
  <input type="sumit" value="提交"/>
</form>
阅读全文
0 0
原创粉丝点击