zoukankan      html  css  js  c++  java
  • 页面载入

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    </head>
    <body>
    <form action="">
        <p>username:
            <input type="text" id="d1">
            <span style="color: red"></span>
        </p>
        <p>password:
            <input type="password" id="d2">
            <span style="color: red"></span>
        </p>
        <input type="button" id="btn" value="注册">
    </form>

    <script>
        $('#btn').click(function () {
            // 获取用户输入的用户名和密码
            var userNameVal = $('#d1').val();
            var passWordVal = $('#d2').val();
            // 依次判断用户名和密码是否为空
            if(userNameVal.length===0){
                // 在username框后面的span标签中添加提示信息
                $('#d1').next().text('用户名不能为空')
            }
            if(passWordVal.length===0){
                $('#d2').next().text('密码不能为空 你个大帅比')
            }
        })
    </script>
    </body>
    </html>
  • 相关阅读:
    Zepto源码分析-动画(fx fx_method)模块
    CSS3用法理解
    移动端网页meta设置和响应式
    javascript基础-正则表达式
    net core 2.x
    angular
    .net core 2.x
    .net core 2.x
    DDD
    DDD
  • 原文地址:https://www.cnblogs.com/huaobin/p/14162602.html
Copyright © 2011-2022 走看看