JavaScript 基础,登录验证

    1. <script></script>的三种用法:
      1. 放在<body>中
      2. 放在<head>中
      3. 放在外部JS文件中
    2. 三种输出数据的方式:
      1. 使用 document.write() 方法将内容写到 HTML 文档中。
      2. 使用 window.alert() 弹出警告框。
      3. 使用 innerHTML 写入到 HTML 元素。
        1. 使用 "id" 属性来标识 HTML 元素。
        2. 使用 document.getElementById(id) 方法访问 HTML 元素。
        3. 用innerHTML 来获取或插入元素内容。

    3. 登录页面准备:
      1. 增加错误提示框。
      2. 写好HTML+CSS文件。
      3. 设置每个输入元素的id
    4. 定义JavaScript 函数。
      1. 验证用户名6-20位
      2. 验证密码6-20位
    5. onclick调用这个函数。
 1 .box {
 2     border: 1px solid #cccccc;
 3     position: absolute;
 4     top: 25px;
 5     left: 40px;
 6     float: left;
 7     height: 300px;
 8     width: 400px;
 9 }
10 
11 h2 {
12     font-family: 华文楷体;
13     font-size: 28px;
14     text-align: center;
15     background: #cccccc;
16     margin-top: auto;
17     height: 40px;
18     width: 400px;
19 }
20 .input_box {
21     height: 60px;
22     width: 80px;
23     margin-left: 10%;
24 }
25 
26 input {
27     align-self: center;
28     height: 30px;
29     width: 280px;
30 
31 }
32 
33 button {
34     align-content: center;
35     font-family: 华文楷体;
36     font-size: 28px;
37     text-align: center;
38     background: #cccccc;
39     height: 40px;
40     width: 300px;
41 }
 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>登录</title>
 6     <link href="../static/css/1.css" rel="stylesheet" type="text/css">
 7 
 8     <script>
 9         function fnLogin() {
10             var oUname = document.getElementById("uname")
11             var oError = document.getElementById("error_box")
12             var oPassward = document.getElementById("upass")
13             if (oUname.value.length<6){
14                 oError.innerHTML = "用户名至少6位"
15             }
16             if(oUname.value.length>6&oPassward.value.length<6){
17             oError.innerHTML="密码至少为6位"
18         }
19         }
20     </script>
21 </head>
22 <body>
23     <div class="box">
24         <h2>登录</h2>
25 
26         <div class="input_box">
27             <input type="text" id="uname" placeholder="请输入用户名">
28         </div>
29         <div class="input_box">
30             <input type="password" id="upass" placeholder="请输入密码">
31         </div>
32         <div id="error_box"><br></div>
33         <div class="input_box">
34             <button onclick="fnLogin()">登录</button>
35         </div>
36 
37     </div>
38 </body>
39 </html>

转载于:https://www.cnblogs.com/l-j-l/p/7732454.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/391003.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

使用final类的作用是什么?

问题&#xff1a;使用final类的作用是什么&#xff1f; 我在看一本关于Java的书&#xff0c;它里面说你可以定义一个类为final。我搞不明白有什么地方会被用到这样。 我是一个编程萌新。我想知道程序员在他们的程序里面都是怎么用fianl类的。如果知道他们是什么时候使用的话&…

photoshop cc_如何使用Photoshop CC将图片变成卡通

photoshop ccA fun photo effect is to make a photo look like a cartoon. In this tutorial you will learn how to use Photoshop CC to make a photo look like a cartoon drawing.有趣的照片效果是使照片看起来像卡通漫画。 在本教程中&#xff0c;您将学习如何使用Photos…

从数据角度探索在新加坡的非法毒品

All things are poisons, for there is nothing without poisonous qualities. It is only the dose which makes a thing poison.” ― Paracelsus万物都是毒药&#xff0c;因为没有毒药就没有什么。 只是使事物中毒的剂量。” ― 寄生虫 执行摘要(又名TL&#xff1b; DR) (Ex…

Android 自定义View实现QQ运动积分抽奖转盘

因为偶尔关注QQ运动&#xff0c; 看到QQ运动的积分抽奖界面比较有意思&#xff0c;所以就尝试用自定义View实现了下&#xff0c;原本想通过开发者选项查看下界面的一些信息&#xff0c;后来发现积分抽奖界面是在WebView中展示的&#xff0c;应该是在H5页面中用js代码实现的&…

瑞立视:厚积薄发且具有“工匠精神”的中国品牌

一家成立两年的公司&#xff1a;是如何在VR行业趋于稳定的情况下首次融资就获得如此大额的金额呢&#xff1f; 2017年VR行业内宣布融资的公司寥寥无几&#xff0c;无论是投资人还是消费者对这个 “宠儿”都开始纷纷投以怀疑的目光。但就在2017年7月27日&#xff0c;深圳市一家…

苹果系统使用svg 动画_为什么要使用SVG图像:如何为SVG设置动画并使其快速闪电化

苹果系统使用svg 动画我们为什么要使用SVG&#xff1f; (Why Are We Using SVG?) The web development sector is growing at a rapid pace, and SVG (scalable vector graphics) images are becoming more popular. As vector images, SVGs are composed of mathematical equ…

CSV模块的使用

CSV模块的使用 1、csv简介 CSV (Comma Separated Values)&#xff0c;即逗号分隔值&#xff08;也称字符分隔值&#xff0c;因为分隔符可以不是逗号&#xff09;&#xff0c;是一种常用的文本 格式&#xff0c;用以存储表格数据&#xff0c;包括数字或者字符。很多程序在处理数…

Java里面遍历list的方式

问题&#xff1a;Java里面遍历list的方式 对于Java语言有点陌生&#xff0c;我尝试熟悉遍历list&#xff08;或者其他集合&#xff09;的所有方法&#xff08;或者是其他正确的语法&#xff09;和它们每一个方法的优缺点 给定 List的list对象&#xff0c;我知道有下列方法去循…

python 重启内核_Python从零开始的内核回归

python 重启内核Every beginner in Machine Learning starts by studying what regression means and how the linear regression algorithm works. In fact, the ease of understanding, explainability and the vast effective real-world use cases of linear regression is…

bzoj千题计划282:bzoj4517: [Sdoi2016]排列计数

http://www.lydsy.com/JudgeOnline/problem.php?id4517 组合数错排公式 #include<cstdio> #include<iostream>using namespace std;#define N 1000001const int mod1e97;long long fac[N],inv[N],f[N];void read(int &x) {x0; char cgetchar();while(!isdigit…

chrome启用flash_如何在Google Chrome中启用Adobe Flash Player

chrome启用flashRemember Adobe Flash player? Its that nifty software that lets websites embed videos and web games. Whole websites can even be powered by Flash.还记得Adobe Flash Player吗&#xff1f; 正是这些漂亮的软件使网站可以嵌入视频和网络游戏。 整个网站…

怎么样把Java的字符串转化为字节数组?

问题&#xff1a;怎么样把Java的字符串转化为字节数组 有没有任何方法把Java的字符串转化为字节数组 我尝试这样: System.out.println(response.split("\r\n\r\n")[1]); System.out.println("******"); System.out.println(response.split("\r\n\r\…

Forward团队-爬虫豆瓣top250项目-模块开发过程

项目托管平台地址:https://github.com/xyhcq/top250 开发模块功能: 写入文件功能 开发时间:3小时 实现将爬取到的信息写入到文件中的功能 实现过程&#xff1a; # 打开文件 fopen("top250.txt","w") 在别的队员写的代码基础上&#xff0c;加入功能代码 de…

CSS3 outline-offset 属性 项目中input会遇到

outline在一个声明中设置所有的轮廓属性。outline:颜色&#xff08;outline-line&#xff09;样式&#xff08;outline-style&#xff09;宽度&#xff08;outline-width&#xff09; outline-offset 属性对轮廓进行偏移&#xff0c;并在边框边缘进行绘制。 轮廓在两方面与边框…

回归分析中自变量共线性_具有大特征空间的回归分析中的变量选择

回归分析中自变量共线性介绍 (Introduction) Performing multiple regression analysis from a large set of independent variables can be a challenging task. Identifying the best subset of regressors for a model involves optimizing against things like bias, multi…

winform窗体模板_如何验证角模板驱动的窗体

winform窗体模板介绍 (Introduction) In this article, we will learn about validations in Angular template-driven forms. We will create a simple user registration form and implement some inbuilt validations on it. Along with the inbuilt validations, we will a…

【loj6191】「美团 CodeM 复赛」配对游戏 概率期望dp

题目描述 n次向一个栈中加入0或1中随机1个&#xff0c;如果一次加入0时栈顶元素为1&#xff0c;则将这两个元素弹栈。问最终栈中元素个数的期望是多少。 输入 一行一个正整数 n 。 输出 一行一个实数&#xff0c;表示期望剩下的人数&#xff0c;四舍五入保留三位小数。 样例输入…

查找满足断言的第一个元素

问题&#xff1a;查找满足断言的第一个元素 我刚刚开始使用Java 8的lambdas&#xff0c;我尝试去实现一些我在函数式语言里面经常用的 例如&#xff0c;大部分的函数式语言里有一些查找函数&#xff0c;针对序列或者list进行操作&#xff0c;返回使得断言为真的第一个元素。我…

Lock和synchronized的选择

学习资源:http://www.cnblogs.com/dolphin0520/p/3923167.html 一.java.util.concurrent.locks包下常用的类 1.Lock public interface Lock { void lock();//用来获取锁。如果锁已被其他线程获取&#xff0c;则进行等待。void lockInterruptibly() throws InterruptedException…

python 面试问题_值得阅读的30个Python面试问题

python 面试问题Interview questions are quite tricky to predict. In most cases, even peoples with great programming ability fail to answer some simple questions. Solving the problem with your code is not enough. Often, the interviewer will expect you to hav…