当前位置:网站首页>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
边栏推荐
- 【BW16 应用篇】安信可BW16模组与开发板更新固件烧录说明
- Mobile phones and computers can be used, whole people, spoof code connections, "won't you Baidu for a while" teach you to use Baidu
- Golang — 命令行工具cobra
- Qt学习19 Qt 中的标准对话框(上)
- 双向链表(我们只需要关注插入和删除函数)
- Golang — template
- Students who do not understand the code can also send their own token, which is easy to learn BSC
- [how to solve FAT32 when the computer is inserted into the U disk or the memory card display cannot be formatted]
- 记录关于银行回调post请求405 问题
- The network card fails to start after the cold migration of the server hard disk
猜你喜欢
太阳底下无新事,元宇宙能否更上层楼?
User and group command exercises
GoLand 2021.2 configure go (go1.17.6)
How to use lxml to judge whether the website announcement is updated
JVM family - overview, program counter day1-1
Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
Mysql:insert date:SQL 错误 [1292] [22001]: Data truncation: Incorrect date value:
3D vision - 2 Introduction to pose estimation - openpose includes installation, compilation and use (single frame, real-time video)
Can newly graduated European college students get an offer from a major Internet company in the United States?
[développement technologique - 24]: caractéristiques des technologies de communication Internet des objets existantes
随机推荐
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
Field problems in MySQL
Flutter动态化 | Fair 2.5.0 新版本特性
Record 405 questions about bank callback post request
太阳底下无新事,元宇宙能否更上层楼?
The shadow of the object at the edge of the untiy world flickers, and the shadow of the object near the far point is normal
CVPR 2022 | interpretation of 6 excellent papers selected by meituan technical team
[机缘参悟-37]:人感官系统的结构决定了人类是以自我为中心
GoLand 2021.1.1: configure the multi line display of the tab of the open file
[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered
Qt学习23 布局管理器(二)
[développement technologique - 24]: caractéristiques des technologies de communication Internet des objets existantes
SQL Injection (GET/Select)
logback日志的整理
Sequence table (implemented in C language)
Go language unit test 5: go language uses go sqlmock and Gorm to do database query mock
常见的几种最优化方法Matlab原理和深度分析
The solution of Chinese font garbled code in keil5
[technology development-24]: characteristics of existing IOT communication technology