zoukankan      html  css  js  c++  java
  • 表单提交

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="renderer" content="webkit">
        <link rel="stylesheet" href="./public.css">
        <title>Title</title>
        <style>
            .form-box{
                 50%;
                margin: 40px auto 0;
            }
            .form-box-other{
                 100%;
                display: flex;
                margin-bottom: 30px;
            }
            .form-box-other span{
                 200px;
                height: 50px;
                display: flex;
                align-items: center;
                justify-content: center;
                font-weight: 800;
                color: #8e8e8e;
            }
            .form-box-other input{
                flex: 1;
                padding-left: 10px;
            }
            button{
                display: block;
                 80%;
                margin: 0 auto;
                height: 50px;
                font-size: 20px;
                font-weight: 800;
            }
            #erro-tips{
                display: block;
                 80%;
                margin: 0 auto;
                height: 50px;
                font-size: 20px;
                color: darkred;
                font-weight: 800;
                text-align: center;
                line-height: 50px;
            }
        </style>
    </head>
    <body>
        <div class="form-box">
            <div class="form-box-other">
                <span>You name</span>
                <input type="text" placeholder="You name">
            </div>
            <div class="form-box-other">
                <span>Your credit card</span>
                <input type="text" placeholder="Your credit card">
            </div>
            <div class="form-box-other">
                <span>Your Github address</span>
                <input type="text" placeholder="Your Github address">
            </div>
            <div class="form-box-other">
                <span>Your email address</span>
                <input type="text" placeholder="Your email address">
            </div>
            <button id="submit">Submit</button>
            <span id="erro-tips"></span>
        </div>
    </body>
    </html>
    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
    <script>
      jQuery(function(){
        var input = $('input');
        var submit = $('#submit');
        submit.click(function(){
          if (!input[0].value) {
            $("#erro-tips").html("请填写完整手机号")
          } else if (!input[1].value) {
            $("#erro-tips").html("请填写您的信用卡")
          } else if (!input[2].value) {
            $("#erro-tips").html("请填写您的Github地址")
          } else if (!input[3].value) {
            $("#erro-tips").html("请填正确的邮箱地址")
          } else {
            $.ajax({
              url: "//40.125.162.90:7800/api/user/info",
              type: "POST",
              data: {
                name: input[0].value,
                walletAddress: input[1].value,
                gitHub: input[2].value,
                email: input[3].value
              },
              success:function (data) {
                if (data.code === '200') {
                  $("#erro-tips").html("提交成功!感谢参与!")
                } else {
                  $("#erro-tips").html(data.msg)
                }
              }
            })
          }
        })
      })
    </script>
  • 相关阅读:
    Java之JDK的下载与安装,java环境变量的配置,Editplus的下载与使用
    JAVA基础语法
    数据库设计
    数据库练习题
    连接查询,子查询,联合查询
    Java内存管理-掌握虚拟机类加载器(五)
    Java内存管理-掌握虚拟机类加载机制(四)
    Java内存管理-JVM内存模型以及JDK7和JDK8内存模型对比总结(三)
    Java内存管理-初始JVM和JVM启动流程(二)
    Java内存管理-程序运行过程(一)
  • 原文地址:https://www.cnblogs.com/dujunfeng/p/8445227.html
Copyright © 2011-2022 走看看