当前位置:网站首页>Broadcast platform, the use of the node generated captcha image, and validate
Broadcast platform, the use of the node generated captcha image, and validate
2022-08-03 00:37:00 【Cloud Leopard Network Technology】
搭建直播平台,使用node生成验证码图片,并进行验证
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
<title>验证码测试</title>
</head>
<body>
<div id="box"></div>
<button id="btn">刷新</button>
<input type="text" id="ipt" />
<span id="span"></span>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script>
const box = document.querySelector('#box')
const btn = document.querySelector('#btn')
const ipt = document.querySelector('#ipt')
const span = document.querySelector('#span')
// 存放正确的验证码文本
let text = ''
// 获取验证码图片和文本
function getInfo() {
$.get('http://127.0.0.1/getInfo', (res) => {
// 正确验证码的信息
text = res.text
// res.data是一个验证码图片 svg标签
box.innerHTML = res.data
console.log(text)
})
}
getInfo()
btn.addEventListener('click', getInfo)
ipt.addEventListener('blur', function (e) {
if (this.value.toLowerCase() === text.toLowerCase()) {
span.innerHTML = '验证通过'
span.style.color = 'green'
} else {
span.innerHTML = '验证不通过'
span.style.color = 'red'
}
})
</script>
</body>
</html>
That is broadcast platform,使用node生成验证码图片,并进行验证, 更多内容欢迎关注之后的文章
边栏推荐
猜你喜欢
随机推荐
JS函数防抖&函数节流及其使用场景
【STM32学习3】DMA基础操作
[C题目]力扣142. 环形链表 II
搭建Spark开发环境(第二弹)
Ansible安装与配置
单例模式你会几种写法?
Flink-SQL
If the watermark according to how to realize the function
任务四 机器学习库Scikit-learn
go os 包
终于明白:有了线程,为什么还要有协程?
word操作:单独调整英文字体
增删改查这么多年,最后栽在MySQL的架构设计上!
【学习笔记】博弈论
微软SQL服务器被黑客入侵以窃取代理服务的带宽
[C题目]力扣141. 环形链表
【TypeScript】深入学习TypeScript类(上)
总结嵌入式C语言难点(2部分)
The interviewer asked me: delete library, in addition to run do?
【DEBUG】ImportError: Unable to import required dependencies: numpy: DLL load failed: 找不到指定的模块。