当前位置:网站首页>(JS) use the properties and methods of the string object to realize the registration and login functions. The length of the user name is required to be in the range of 3-10 and the password is 6-20 ch
(JS) use the properties and methods of the string object to realize the registration and login functions. The length of the user name is required to be in the range of 3-10 and the password is 6-20 ch
2022-04-22 23:13:00 【Did you add pepper?】
**
subject : utilize String The properties and methods of the object realize the functions of registration and login , The length of the user name is required to be 3-10 Within the scope of , Password in 6-20 position .
Ideas : Do a simple login registration , It doesn't need to be too complicated !
Call two functions in one general function , use switch Function realization , For login and registration respectively . A little more detail will ok Slightly . The code is not perfect , Too lazy to write any more , Just lie down .
<!DOCTYPE html >
<html>
<head>
</head>
<body>
<al>
<ul>
<center><p> user name :
<input id="a" type="text" value=" The user name is in the length of 3-10 Within the scope of ">
</p>
<p> password :
<input id="b" type="text" value=" Password in 6-20 position ">
</p>
<input id="c" type="button" value=" register " onClick="fun(1)">
<input id="d" type="button" value=" Sign in " onClick="fun(2)">
</center>
</ul>
</al>
<script>
var a=new String("111")
var b =new String("222")
var c,i,j
function fun(c){
a = document.getElementById("a").value// Get the value of the text box
b = document.getElementById("b").value
switch(c){
case 1:zhuce()// Used to obtain the judgment input value , Registration part
i=a
j =b
break
case 2:denglu()// Used to verify whether it is consistent with the registration , Login section
break
}
function zhuce(){
// Used to obtain the judgment input value , Registration part
if (Boolean(a) && Boolean(b)){
// If two characters are not empty
if(a.length>=3 && a.length<=10 ){
// Judge user name input
if (b.length>=6 && b.length<=20){
alert(" Registered successfully !")
}
else{
alert(" Wrong password !")
}
}
else{
alert(" User name input error !")
}
}
else{
alert(" Input error ! Please re-enter your user name and password !")
}
}
function denglu(){
// Used to verify whether it is consistent with the registration , Login section
a = document.getElementById("a").value
b = document.getElementById("b").value
if (a==i){
if(b==j){
alert(" Login successful !")
}
else{
alert(" Login failed !")
}
}
else{
alert(" Login failed !")
}
}
}
</script>
</body>
</html>
The operation result is as shown in the figure :


版权声明
本文为[Did you add pepper?]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204222309549481.html
边栏推荐
- How to treat, Kwai, know and other platforms will display the user's IP's functions locally?
- 【LeetCode 剑指 Offer 34. 二叉树中和为某一值的路径(中等)】
- JS计算圆的周长和面积
- 光学指纹模组解锁方案设计指纹锁方案
- win10 安装mujoco,mujoco_py,gym
- Cron expression
- Go的定时器之Time.Ticker
- (JS)利用String对象的属性和方法实现注册和登录功能,要求用户名长度在3-10范围内,密码在6-20位
- [hctf 2018] Unicode spoofing of admin
- [BJDCTF2020]Easy MD5
猜你喜欢
随机推荐
Regular expression -- IP address matching
High number | [differential calculus and application of multivariate functions] error prone problems and detailed explanation of Li Lin 880
js中对Array进行遍历
[hctf 2018] Unicode spoofing of admin
bullwhip effect
企业微信扫码登录后台管理系统,如何修改二维码样式
[HCTF 2018]admin之Flask之session伪造
MySQL最新教程通俗易懂
LeetCode 16. 最接近的三数之和(中等、数组)day13
登录功能&新增文章功能的测试点提取以及测试用例编写
Detailed explanation of Gentoo system installation steps
ansible作业1
正则表达式——IP地址匹配
Numeric type and sequence type
yolov1论文笔记摘抄
如何快速转载CSDN中的博客
WebRTC系列-WebRTC基础(七)NAT、stun和turn(1)
MySQL日志保留策略:设置binlog日志保存天数、文件大小限制
LeetCode 414. 第三大的数(简单、数组)day13
必刷2022年江西最新消防设施操作员模拟题库及答案

![[BJDCTF2020]Easy MD5](/img/94/08b19ead7c48549340b29bc8f34033.png)







