Form表单提交前进行JS验证的3种方式
1. 提交按鈕的onclick事件中驗證
<script type="text/javascript">
???????? function check(form) {
???????? return true;
???????? }
</script>
<form>
?<input type="submit" name="submit1" value="登陸" οnclick="return check(this.form)" />
</form>
?
2. Form表單的onsubmit事件中驗證
<script type="text/javascript">
???????? function check(form) {
???????? return true;
???????? }
</script>
<form οnsubmit="return check(this)">
?<input type="submit" name="submit1" value="登陸" />
</form>
?
3. 用JS進行提交
<script type="text/javascript">
???????? function check(form) {
???????? document.myform.submit();
???????? }
</script>
<form name="myform">
?<input type="button" name="submit1" value="登陸" οnclick="check(this.form)" />
</form>
轉載于:https://www.cnblogs.com/fengjunkuan/p/4810159.html
總結
以上是生活随笔為你收集整理的Form表单提交前进行JS验证的3种方式的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: OGRE 2.1 Windows 编译
- 下一篇: 15年悦翔v5跑了4万多公里,没有交通事