js 键盘事件 理解

layui.use(['jquery', 'table', 'layer', 'form'], function () {
    // 加载layui模块,使用其推荐的【预先加载】方式,详见官网【模块规范】一节
    var $ = layui.$;
    var table = layui.table;
    var layer = layui.layer;
    var form = layui.form;
    var table = layui.table;

    //监听提交
    form.on('submit(formDemo)', function (data) {
        $.ajax({
            url: basePath + 'operator/edit.do',
            data: data.field,
            type: 'post',
            dataType: 'json',
            success: function (result) {
                if (result.success) {
                    layer.msg(result.msg);
                    window.location.href = basePath + '/jsp/operator/lot.jsp';
                } else {
                    layer.msg(result.msg);
                }
            },
            error: function () {
                console.log("ajax error");
            }
        });
        // 阻止表单跳转
        return false;
    });
});

function KeyDown() {
    if (event.keyCode == 13) {
        event.returnValue = false;
        event.cancel = true;
        Form.btnsubmit.click();
    }
}


<%@page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ include file="/jsp/common.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath%>">
    <meta charset="utf-8">
    <title>用户管理</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="description" content="This is my page">
    <link rel="stylesheet" type="text/css" href="<%=basePath %>js/layui-v2.5.5/layui/css/layui.css" charset="utf-8">
    <style type="text/css">
        .container{
            width: 360px;
            height: 100px;
            min-height: 220px;
            max-height: 220px;
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            margin: auto;
            padding: 20px;
            z-index: 130;
            border-radius: 8px;
            background-color: #fff;
            box-shadow: 0 3px 18px rgba(100, 0, 0, .5);
            font-size: 16px;
        }
        .close{
            background-color: white;
            border: none;
            font-size: 18px;
            margin-left: 360px;
            margin-top: -10px;
        }

        .layui-input{
            border-radius: 5px;
            width: 200px;
            height: 40px;
            font-size: 15px;
        }
        .layui-form-item{
            margin-left: -20px;
        }
        #logoid{
            margin-top: -16px;
            padding-left:150px;
            padding-bottom: 15px;
        }
        .layui-btn{
            margin-left: -50px;
            border-radius: 5px;
            width: 250px;
            height: 40px;
            font-size: 15px;
        }
        .verity{
            width: 120px;
        }
        .font-set{
            font-size: 13px;
            text-decoration: none;
            margin-left: 120px;
        }
        a:hover{
            text-decoration: underline;
        }

    </style>
</head>
<body>
<form class="layui-form"  name="Form" action="" method="post">
    <div class="container">
        <button class="close" title="关闭">X</button>
        <div class="layui-form-mid layui-word-aux">
            <label class="effect06 x-box-item effect06-default" id="label-1013"
                   style="font-size: 20px;margin-left: 60px"></label>
        </div>
        <div class="layui-form-item" style="margin-top:80px">
            <label class="layui-form-label">工号</label>
            <div class="layui-input-block">
                <input type="text" name="_workId"  onkeydown="KeyDown()" id="_workId" required  lay-verify="required" placeholder="请输入工号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-top:30px">
            <div class="layui-input-block">
                <button   name="btnsubmit"  id="btnsubmit" class="layui-btn" lay-submit lay-filter="formDemo">登陆</button>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript" src="<%=basePath %>js/layui-v2.5.5/layui/layui.js" charset="utf-8"></script>
<script>
    var basePath = "<%=basePath %>";
</script>
<script type="text/javascript" src="<%=basePath %>jsp/operator/index.js?v=20201"></script>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值