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

xiaoxiao2021-02-28  82

function check(){    var name = document.getElementById("name").value;    if(name ==  null || name == ''){         alert("用户名不能为空");         return false;    }    return true; } <form name="form" action="跳转的页面" method="post"  οnsubmit="return check(this.form)">   <input type="text" id="name"/>   <input type="sumit" value="提交"/> </form>
转载请注明原文地址: https://www.6miu.com/read-74670.html

最新回复(0)