当前位置:网站首页>JS general form submission 1-onsubmit
JS general form submission 1-onsubmit
2022-07-03 13:54:00 【Cloud and cloud discoloration 1】
During form submission , If you directly click on the form submit Button will submit the form , But this method is not applicable when verification is needed .
Therefore, it usually happens in form In the statement of onsubmit Methods , Add fields to be verified in this method .
The method is as follows :
1、form Forms
<form id='form1' action='' method='' omsubmit='return checkForm()'>
<input type='text' name='username' value=''/>
<input type='password' name='pwd' value =''/>
<input type='password' name='pwd2' value =''/>
<button type='submit'> Submit <button/>
<form/>
2、 Statement onsubmit Method
<script>
function checkForm(){
var form = document.getElementById('form1');
// It can be modified here input
// Go to the next step
return true;
}
<script/>
3、 Submit Form
Triggered when the form is submitted checkForm, You can verify the password twice , You can also verify the validity of the user name , And if something goes wrong return fasle;, This will prevent the submission of the form .
It's just right onsubmit An attempt to , Then I will try to write general submit Method , And the use of ajax Method of submission , In this way, there is no way to refresh the submission form and ignore the form items to write the submission form .
above .
Refer to the connection :
https://www.cnblogs.com/web-wjg/p/7894657.html
边栏推荐
- JVM family - overview, program counter day1-1
- Go 1.16.4: manage third-party libraries with Mod
- Go language unit test 3: go language uses gocovey library to do unit test
- Flutter动态化 | Fair 2.5.0 新版本特性
- [technology development-24]: characteristics of existing IOT communication technology
- Can newly graduated European college students get an offer from a major Internet company in the United States?
- Go language web development series 27: Gin framework: using gin swagger to implement interface documents
- Father and basketball
- Qt学习25 布局管理器(四)
- Common network state detection and analysis tools
猜你喜欢
Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
[bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
Resource Cost Optimization Practice of R & D team
从零开始的基于百度大脑EasyData的多人协同数据标注
Go language web development series 27: Gin framework: using gin swagger to implement interface documents
Qt学习17 对话框及其类型
Libuv Library - Design Overview (Chinese version)
研发团队资源成本优化实践
Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
The latest BSC can pay dividends. Any B usdt Shib eth dividend destruction marketing can
随机推荐
如何使用lxml判断网站公告是否更新
Flutter动态化 | Fair 2.5.0 新版本特性
Go 1.16.4: manage third-party libraries with Mod
SQL Injection (GET/Search)
Leetcode-1175. Prime Arrangements
Bidirectional linked list (we only need to pay attention to insert and delete functions)
KEIL5出现中文字体乱码的解决方法
Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
双向链表(我们只需要关注插入和删除函数)
Implementation of Muduo asynchronous logging
Screenshot of the operation steps of upload labs level 4-level 9
Qt学习23 布局管理器(二)
Qt学习20 Qt 中的标准对话框(中)
php 迷宫游戏
JVM系列——概述,程序计数器day1-1
【BW16 应用篇】安信可BW16模组与开发板更新固件烧录说明
金属有机骨架MOFs装载非甾体类抗炎药物|ZIF-8包裹普鲁士蓝负载槲皮素(制备方法)
The solution of Chinese font garbled code in keil5
树的深入和广度优先遍历(不考虑二叉树)
[how to earn a million passive income]