首页 > 其他分享 >登录页面

登录页面

时间:2023-06-30 13:12:58浏览次数:40  
标签:const 登录 color xhr getElementById document email 页面

<!DOCTYPE html>
<html>
<head>
<title>Register</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
}

.container {
max-width: 400px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
text-align: center;
margin-bottom: 20px;
}

.form-group {
margin-bottom: 20px;
}

label {
display: block;
font-weight: bold;
margin-bottom: 5px;
}

input[type="email"],
input[type="password"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}

button {
display: block;
width: 100%;
padding: 10px;
background-color: #4caf50;
color: #ffffff;
border: none;
border-radius: 4px;
cursor: pointer;
}

button:hover {
background-color: #45a049;
}

.text-center {
text-align: center;
}
.form-group>p{
color: #ff4222;
}
</style>
</head>
<body>
<div class="container">
<h1>Register</h1>
<form>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<!-- require 第一是要求必填,第二要求格式正确,否则不submit-->
<p id="emailTip"></p>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<p id="passWordTip"></p>
</div>
<div class="form-group">
<label for="passwordAgain">Password:</label>
<input type="password" id="passwordAgain" required>
</div>
<div class="text-center">
<button type="submit">Register</button>
</div>
</form>
</div>
</body>
</html>
<script>
const email=document.getElementById('email')
const emailTip=document.getElementById('emailTip')
email.onchange=()=> {
if (/^[0-9a-zA-Z._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/.test(email.value)) { //通过正则判断格式

const xhr = new XMLHttpRequest()
const params = `/test_email?email=${email.value}`
xhr.open('get', params, true)

xhr.onreadystatechange = () => {
//当后端的response成功回转后,readyState将变成为4,status将变为200
if (xhr.readyState === 4 && xhr.status === 200) {

console.log(xhr.responseText)//输出后端回应给前端的信息
if (xhr.responseText) {
emailTip.innerHTML =xhr.responseText
}

}
}
xhr.send()
return true
}
document.getElementById('emailTip').innerHTML = '邮箱格式不正确'

}
document.getElementsByTagName('form')[0].onsubmit = () => {
const password = document.getElementById('password').value//定义password的值
const passwordAgain = document.getElementById('passwordAgain').value
if (password === passwordAgain) {
return true

}
document.getElementById('passWordTip').innerHTML = '两次密码不一致'
return false
}


</script>

标签:const,登录,color,xhr,getElementById,document,email,页面
From: https://www.cnblogs.com/ckyjbd/p/17516431.html

相关文章

  • 餐厅页面
    <!doctypehtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-sc......
  • 关于HTML页以Get方法向asp.net页面传值乱码的解决
    这个问题是最近偶然发现的,朋友说我个人做那个基于Lucene的搜索引擎,存在一个问题,就是只能搜索英文,不能搜索中文。我把代码仔细看了一下,没发现问题,但是在测试的时候确实存在这样的问题。我查看传值之后的参数,全部是乱码或者空格,立即觉得是传递过程中编码的问题。后来在web.config中添......
  • PC网站如何实现微信扫码登录
    不管你运营什么类型的网站,用户注册都是很重要的一个环节,用户注册的方式也是很多的,比如邮箱注册、手机号注册、第三方授权登录等。其中,第三方授权登录是最常用的一种方式,微信扫码登录是其中的一种,但是微信扫码登录的实现方式有很多种,比如公众号扫码,小程序扫码,网页扫码等。本文将介......
  • [GPT] vue 的 quasar 框架 在 layout 模版中 如何获取 子页面当前使用的 useMeta
     在Quasar框架中,用VueRouter的meta字段来获取子页面当前使用的useMeta。首先,您需要在路由配置中设置子页面的meta字段。例如:  constroutes=[{path:'/page',component:PageComponent,meta:{useMeta:{//在这里定义您......
  • 内网使用postman测试websocket接口(无法登录的情况下)
    postman测试websocket接口。但是发现老版本的postman不支持websocket接口的测试。于是直接上最新版本postman。打开postman,new,选择websocket。发现选不了,提示:youneedtobeinaworkspacetoperformthisaction.然后我去工作台,发现强制要登录!!!但是问题在于:我这公司电脑不......
  • 注册功能 ,前端登录注册页面
    目录1异步发送短信1.1视图类1.2序列化类加入万能验证码2注册功能3.1视图类3.2序列化类补充3前端注册页面分析3.1Header.vue3.2Login.vue4前端登录注册页面复制4.1Login.vue4.2Register.vue4.3Header.vue5前端登录功能6前端注册功能1异步发送短信#原来的发送短......
  • Spring Security实现多用户系统登录
    由于管理层的突发奇想,硬要把我负责的系统塞到其他的项目中去,而系统之间的用户系统又不同,如果要合并到一起,那改动将是非常大,于是就产生这个多用户系统登录的问题。因为userDetailService是通过用户名来查找用户信息的,所以具体实现得通过多个userDetailService提供用户信息,每个用户......
  • Centos7 集群SSH无密码用户免密登录配置
    例:配置集群1的A,B,C三台Centos7的test无密码用户免密登录1,在A机器执行ssh-kengen生成秘钥,一路回车[root@lmslms]#su-test[test@test~]#ssh-keygenGeneratingpublic/privatersakeypair.Enterfileinwhichtosavethekey(/root/.ssh/id_rsa):Enterpassphrase......
  • 记录pc网站微信登录(内嵌二维码方式)
    官方文档地址:https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html第一步:引入官方js  http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js或者把js下载下来放到自己项目里引用 好处是可以自己修改一些东西!(functio......
  • 以root身份登录ubuntu桌面
    1、用普通账号登录后,给root设置密码。如下图2、默认情况下,登录界面是不允许使用root登录的。但修改以下文件的配置信息就可使用root身份登录。如下图(图中的VI命令可以更改为gedit命令【文本编辑器】)......