当前位置:网站首页>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
边栏推荐
- 顺序表(C语言实现)
- Go: send the get request and parse the return JSON (go1.16.4)
- Record 405 questions about bank callback post request
- Go language web development series 30: gin: grouping by version for routing
- Implementation of Muduo accept connection, disconnection and sending data
- Shell timing script, starting from 0, CSV format data is regularly imported into PostgreSQL database shell script example
- Leetcode-1175. Prime Arrangements
- Flutter dynamic | fair 2.5.0 new version features
- 项目协作的进度如何推进| 社区征文
- [redis] cache warm-up, cache avalanche and cache breakdown
猜你喜欢

太阳底下无新事,元宇宙能否更上层楼?

挡不住了,国产芯片再度突进,部分环节已进到4nm

Students who do not understand the code can also send their own token, which is easy to learn BSC

解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)

Use and design of Muduo buffer class

Go language web development series 29: Gin framework uses gin contrib / sessions library to manage sessions (based on cookies)

Summary of common error reporting problems and positioning methods of thrift

Can newly graduated European college students get an offer from a major Internet company in the United States?

8 Queen question

NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
随机推荐
Stack application (balancer)
Software testing is so hard to find, only outsourcing offers, should I go?
Flutter动态化 | Fair 2.5.0 新版本特性
【电脑插入U盘或者内存卡显示无法格式化FAT32如何解决】
JSON serialization case summary
Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
[机缘参悟-37]:人感官系统的结构决定了人类是以自我为中心
Golang - command line tool Cobra
Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
MySQL 数据增删改查综合案例
Swiftui development experience: the five most powerful principles that a programmer needs to master
Screenshot of the operation steps of upload labs level 4-level 9
【556. 下一个更大元素 III】
Use vscode to view hex or UTF-8 codes
掌握Cypress命令行选项,是真正掌握Cypress的基础
How to use lxml to judge whether the website announcement is updated
Richview trvstyle liststyle list style (bullet number)
软件测试工作那么难找,只有外包offer,我该去么?
Unity EmbeddedBrowser浏览器插件事件通讯
太阳底下无新事,元宇宙能否更上层楼?