当前位置:网站首页>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 !
边栏推荐
- ValueError: Found input variables with inconsistent numbers of samples: [80019456, 26673152]【报错】
- 2021.7.17 notes MySQL other commands
- The combination of text and words perfectly explains the implementation process of MySQL logical backup
- 20000 words + 30 pictures | what's the use of chatting about MySQL undo log, redo log and binlog?
- Login page tablelayout
- 知识图谱 — jieba、pyhanlp、smoothnlp工具实现中文分词(词性表)
- TypeError: conv2d(): argument ‘padding‘ (position 5) must be tuple of ints, not str【报错】
- 飞机大战敌机出场
- Mode= "widthfix" attribute in image tag
- mysql视图基本操作
猜你喜欢

【npm】 无法将“npm”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。

多功能无线遥控艾灸仪芯片-DLTAP703SD

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

idea 2020.1社区版下载体验

How to realize the full-text content retrieval of word, PDF and txt files?

1. OpenCV image basic operation

Uni app label jump

LED带风扇护眼学习台灯触摸芯片-DLT8S12A

2021.7.22 note constraints

2021.7.13笔记 子查询
随机推荐
TS learning notes interface
2021.7.28 notes
What does the number of network request interface layers (2/3 layers) mean
What if MySQL database forgets its password???
Login page tablelayout
Idea packaging war package and war package location
A case to understand MySQL view
LED学习护眼台灯触摸芯片-DLT8T10S-杰力科创
Using Jieba and pyhanlp tools to extract keyword words and sentences
你有没有在MySQL的order by上栽过跟头
Use ETL tools for data migration in salesforce project
js中的函数与DOM获取元素和事件属性的使用
Have you ever stumbled on MySQL's order by
我人都傻了,CompletableFuture和OpenFegin一起使用竟然报错
Knowledge map pyhanlp realizes named body recognition (with named body recognition code)
Visual Studio Code安装教程(超详细)
idea 2020.1社区版下载体验
2021.8.9 note request
兆骑科创海内外引进高层次人才,创新创业项目对接
飞机大战敌机出场