博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
完成登录与注册页面的前端
阅读量:4546 次
发布时间:2019-06-08

本文共 3376 字,大约阅读时间需要 11 分钟。

完成登录与注册页面的HTML+CSS+JS,其中的输入项检查包括:

用户名6-12位

首字母不能是数字

只能包含字母和数字

密码6-12位

注册页两次密码是否一致

 

css文件:

#container{
width: 400px}#header{
background-color: coral}#content{
background-color: aquamarine}#footer{
background-color: coral}

js文件:

function fnLogin() {    var uSer = document.getElementById("user");    var pAss = document.getElementById("pass");    var oError = document.getElementById("error_box");    oError.innerHTML = "
"; // 验证用户名 if (uSer.value.length < 6 || uSer.value.length > 20) { oError.innerHTML = "用户名只能6-20位"; return } else if ((uSer.value.charCodeAt(0) >= 48) && (uSer.value.charCodeAt(0) <= 57)) { oError.innerHTML = "用户名首字母不能是数字"; return } else for (var i = 0; i < uSer.value.length; i++) { if ((uSer.value.charCodeAt(i) < 48) || (uSer.value.charCodeAt(i) > 57) && (uSer.value.charCodeAt(i) < 97) || (uSer.value.charCodeAt(i) > 122)) { oError.innerHTML = "用户名只能由数字和字母组成"; return } } // 验证密码 if (pAss.value.length < 6 || pAss.value.length > 20) { oError.innerHTML = "密码只能6-20位"; return } // 验证弹框 window.alert("登陆成功!")}function fnRegistration() { var uSer = document.getElementById("user"); var pAss = document.getElementById("pass"); var aGain = document.getElementById("again"); var oError = document.getElementById("error_box"); oError.innerHTML = "
"; // 验证用户名 if (uSer.value.length < 6 || uSer.value.length > 20) { oError.innerHTML = "用户名只能6-20位"; return } else if ((uSer.value.charCodeAt(0) >= 48) && (uSer.value.charCodeAt(0) <= 57)) { oError.innerHTML = "用户名首字母不能是数字"; return } else for (var i = 0; i < uSer.value.length; i++) { if ((uSer.value.charCodeAt(i) < 48) || (uSer.value.charCodeAt(i) > 57) && (uSer.value.charCodeAt(i) < 97) || (uSer.value.charCodeAt(i) > 122)) { oError.innerHTML = "用户名只能由数字和字母组成"; return } } // 验证密码 if (pAss.value.length < 6 || pAss.value.length > 20) { oError.innerHTML = "密码只能6-20位"; return } // 验证再次输入的密码 if (aGain.value != pAss.value) { oError.innerHTML = "密码不一致"; return } // 验证弹框 window.alert("注册成功!")}

登陆页面html:

    
练习
Username:
Password:
student
teacher
记住我
 
    
忘记密码?

注册页面html:

    
练习

Username:

Password:

Lnput again:

student teacher

当首字母有数字时:

顺利登陆时:

当密码输入不一致时:

注册成功时:

 

转载于:https://www.cnblogs.com/lwb9511/p/7760087.html

你可能感兴趣的文章
网络是怎样连接的-路由器的包转发操作(上)
查看>>
WPF - EventSetter
查看>>
Superblock mount time is in the future(转载)
查看>>
.Net开源框架列表
查看>>
hadoop 基础, HDFS(块, 元数据)
查看>>
RabbitMQ学习之集群部署
查看>>
Codeforces 1109D. Sasha and Interesting Fact from Graph Theory
查看>>
ASP.NET的URL过滤
查看>>
自己写的Web服务器
查看>>
自定义定时组件
查看>>
简单理解代理模式
查看>>
2-素数打比表
查看>>
性能测试
查看>>
java,枯燥中遇见美丽JFrame,窗体(边界布局)
查看>>
浅谈 Python 的 with 语句
查看>>
使用koa+angular+mysql 完成了一个企业站
查看>>
SQL使用范例
查看>>
转 SQL集合函数中利用case when then 技巧
查看>>
SQL经典语句二
查看>>
IIS6/7/8 WEBserver不能訪问grf报表模板文件的问题
查看>>