获得 layer 文件包后,解压并将 layer 整个文件夹(不要拆分结构) 存放到你项目的任意目录,使用时,只需引入 layer.js 即可
使用时一定他要先引入jq1.8,或者以上版本!!!
下面是提交表单的实列
- <!DOCTYPE html>
- <html>
- <head>
- <Meta charset="utf-8">
- <Meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
- <title></title>
- <script src="__STATIC__/js/mui.min.js"></script>
- <link href="__STATIC__/css/mui.min.css" rel="external nofollow" rel="stylesheet"/>
- <script src="__STATIC__/layer/jquery-2.2.4.min.js"></script>
- <script src="__STATIC__/layer/layer.js"></script>
- <script type="text/javascript" charset="utf-8">
- mui.init();
- </script>
- </head>
- <body>
- <center>
- <ul class="mui-table-view">
- <li class="mui-table-view-cell">商品入库</li>
- </ul>
- </center>
- <form action="{:url('order')}" method="post" class="mui-input-group">
- <div class="mui-input-row">
- <label>商品单号:</label>
- <input type="text" class="mui-input-clear" placeholder=" 请输入用户名" name="order" id="order">
- </div>
- <div class="mui-input-row">
- <label>商品名称:</label>
- <input type="text" class="mui-input-clear" placeholder=" 请输入用户名" name="name" id="name">
- </div>
- <div class="mui-input-row">
- <label>商品单价:</label>
- <input type="text" class="mui-input-clear" placeholder=" 请输入用户名" name="money" id="money">
- </div>
- <div class="mui-input-row">
- <label>商品库存:</label>
- <input type="text" class="mui-input-clear" placeholder=" 请输入用户名" name="stock" id="stock">
- </div>
- <div class="mui-input-row">
- <label>商品备注:</label>
- <input type="text" class="mui-input-clear" placeholder=" 请输入密码" name="remarks" id="remarks">
- </div>
- <div class="mui-button-row">
- <button type="submit" class="mui-btn mui-btn-primary" id="cx">确认</button>
- </div>
- </form>
- <script type="text/javascript">
- $(document).ready(function(){
- $('#cx').click(function(){
- var $1 = $.trim($('#order').val());
- var $2 = $.trim($("#name").val());
- var $3 = $.trim($("#money").val());
- var $4 = $.trim($("#stock").val());
- var $5 = $.trim($("#remarks").val());
- if($1 == ''){
- layer.msg('商品单号不能为空',function() {time:2000});
- return false;
- }
- if($2 == ''){
- layer.msg('请输入商品名称!',function() {time:2000});
- return false;
- }
- if($3 == ''){
- layer.msg('请输入商品单价!',function() {time:2000});
- return false;
- }
- if($4 == ''){
- layer.msg('请输入商品库存!',function() {time:2000});
- return false;
- }
- });
- });
- </script>
- </body>
- </html>
以上这篇使用layer弹窗提交表单时判断表单是否输入为空的例子就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持我们。