当前位置:网站首页>JS to realize simple form verification and select all functions
JS to realize simple form verification and select all functions
2022-07-27 18:47:00 【Rise from the road】
js Realize simple form verification and select all functions
List of articles
One . Form validation

1.body
<div id="d1">
<form action="#" method="post">
user name :<input type="text" placeholder=" Please enter a user name :" onfocus="Mover()" onblur="Mblur(this.value)"/><span id="s1"></span><br />
password : <input type="password" placeholder=" Please input a password :" onfocus="pwd2()" onblur="Hpwd2(this.value)"/><span id="s2"></span>
<br/><input type="submit" value=" Submit "/>
</form>
</div>
2.js
<script> function Mover(){
var s1=document.getElementById('s1'); s1.innerHTML=" User name length cannot be less than 3 position , Greater than 8 position !"; } function Mblur(tet){
if(tet.length>3 && tet.length<8){
var s2=document.getElementById('s1'); s2.innerHTML="<a style='color: green;font-size: 20px;'>√</a>"; }else{
var s3=document.getElementById('s1'); s3.innerHTML="<a style='color: red;font-size: 20px;'> Incorrect user name format !!</a>"; } } function pwd2(){
var s2=document.getElementById('s2'); s2.innerHTML=" Password length cannot be less than 3 position , Greater than 8 position !"; } function Hpwd2(pwd){
if(pwd.length>3 && pwd.length<8){
var s2=document.getElementById('s2'); s2.innerHTML="<a style='color: green;font-size: 20px;'>√</a>"; }else{
var s3=document.getElementById('s2'); s3.innerHTML="<a style='color: red;font-size: 20px;'> The password format is incorrect !!</a>"; } } </script>
Two . Select all

1.body
<table>
<tr>
<td><input type="checkbox" name="c1" onclick="pd()"/></td>
<td><input type="checkbox" name="c1" onclick="pd()"/></td>
<td><input type="checkbox" name="c1" οnclick="pd()"/</td>
</tr>
<tr>
Future generations <input type="checkbox" id="c2" onclick="fun1(0)"/>
Totally unselected <input type="checkbox" id="c3" onclick="fun1(1)"/>
</tr>
</table>
2.js
<script> function a1(a1){
var a=document.getElementsByName('c1'); if(a1){
for(i=0;i<a.length;i++){
a[i].checked=a1; } var b=document.getElementById('c3').checked=false; }else{
for(i=0;i<a.length;i++){
a[i].checked=a1; } var b=document.getElementById('c2').checked=false; } } function fun1(aa){
var a=document.getElementsByName('c1'); if(aa==0){
a1(true); }else{
a1(false); } } function pd(){
var q1=0; var q=0; var q2=document.getElementsByName('c1'); for(i=0;i<q2.length;i++){
if(q2[i].checked){
q1+=1; }else{
q+=1; } } if(q1==q2.length){
var b=document.getElementById('c2').checked=true; var b=document.getElementById('c3').checked=false; }else{
var b=document.getElementById('c2').checked=false; } if(q==q2.length){
var b=document.getElementById('c3').checked=true; var b=document.getElementById('c2').checked=false; }else{
var b=document.getElementById('c3').checked=false; } } </script>
3、 ... and . Summary
Use of this chapter JavaScript Form verification and select all functions are realized , The purpose of the exercise is to call functions .
Where are the deficiencies or better suggestions , Welcome to make complaints about Tucao , There is a little friend who doesn't understand can confide in me , I will reply one by one. , Thank you for your approval , Thank you for your support !
边栏推荐
- MySQL 主从复制数据不一致,怎么办?
- RuntimeError: output with shape [1, 256, 256] doesn‘t match the broadcast shape [3, 256, 256]【报错】
- 2021.7.17 notes MySQL other commands
- MySQL查询列必须和group by字段一致吗?
- Wechat applet wxacode.getunlimited generates applet code
- 浅谈JVM(面试常考)
- 迷你洗衣机触摸芯片-DLT8MA12TS-杰力科创
- Error launching IDEA
- 2021.7.30笔记 索引
- 阿里架构师耗时280个小时整理的1015页分布式全栈小册,轻松入手分布式系统
猜你喜欢

2021.7.12 internal and external connection of notes

MySQL learning Day1 DDL, DML, DQL basic query

V-bind and V-for

Log4j 史诗级漏洞,京东这样的大厂都中招了

2021.7.17笔记 mysql其他命令

2021.7.13笔记 子查询

The song of the virtual idol was originally generated in this way!

Complete set of machine learning classification task effect evaluation indicators (including ROC and AUC)

2021.7.18笔记 mysql数据类型

uniapp H5跨域问题
随机推荐
An analysis of CPU explosion of a smart logistics WCS system in.Net
你想得到想不到的MySQL面试题都在这了(2022最新版)
TypeError: conv2d(): argument ‘padding‘ (position 5) must be tuple of ints, not str【报错】
兆骑科创海内外引进高层次人才,创新创业项目对接
迷你洗衣机触摸芯片-DLT8MA12TS-杰力科创
Basic operations of MySQL view
What if MySQL database forgets its password???
微信小程序 wxacode.getUnlimited生成小程序码
RSA encryption and decryption (compatible with wechat applet environment)
2021.7.30笔记 索引
pandas的to_sql函数使用
Mybtis-Plus常用的内置方法
Login page tablelayout
Visual studio code installation tutorial (super detailed)
js中的函数与DOM获取元素和事件属性的使用
Solve the problem of JSP cascading
idea 2020.1社区版下载体验
RuntimeError: output with shape [1, 256, 256] doesn‘t match the broadcast shape [3, 256, 256]【报错】
我人都傻了,CompletableFuture和OpenFegin一起使用竟然报错
Wechat applet obtains openid, sessionkey, unionid