吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 846|回复: 1
收起左侧

[求助] 想问一下$.metadata.setType("attr","validate");什么意思

[复制链接]
163585580 发表于 2022-4-20 20:12
本帖最后由 163585580 于 2022-4-20 20:13 编辑

想问一下54和55行的$.metadata.setType("attr","valIDAte");和$("#chongzhiForm").validate();什么意思,代码如下


[HTML] 纯文本查看 复制代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
                 pageEncoding="UTF-8"%>
<%@ include file="law.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
        HuiyuanService huiyuanSrv= BeansUtil.getBean("huiyuanService",HuiyuanService.class);
        Huiyuan huiyuan=(Huiyuan)request.getSession().getAttribute("huiyuan");
        if(huiyuan!=null){
                huiyuan=huiyuanSrv.load("where id="+huiyuan.getId());
                request.getSession().setAttribute("huiyuan", huiyuan);
        }

%>

<head>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>学生登录</title>
        <link rel="stylesheet" href="${pageContext.request.contextPath}/e/css/index.css" type="text/css"></link>
        <link rel="stylesheet" href="${pageContext.request.contextPath}/admin/css/web2table.css" type="text/css"></link>

        <link rel="stylesheet" href="${pageContext.request.contextPath}/e/css/box.all.css" type="text/css"></link>

        <script src="${pageContext.request.contextPath}/webui/jquery/jquery-1.12.4.min.js" type="text/javascript"></script>

        <script  type="text/javascript" src="${pageContext.request.contextPath}/webui/jquery/jquery.validate.min.js"></script>
        <script type="text/javascript"  src="${pageContext.request.contextPath}/webui/jquery/jquery.metadata.js" ></script>
        <script type="text/javascript"  src="${pageContext.request.contextPath}/webui/jquery/messages_cn.js" ></script>
        <script type="text/javascript">

                $(function(){

                        $("#btnChongzhi").click(function(){
                                //fadeToggle() 方法在 fadeIn() 和 fadeOut() 方法之间切换。
                                //第一次没有出现的点一下出现
                                $(".shang_box").fadeToggle();
                        });

                        $(".pay_item").click(function(){
                                //单选
                                $(this).addClass('checked').siblings('.pay_item').removeClass('checked');
                                //拿到被选中的属性
                                var dataid=$(this).attr('data-id');
                                //设置被选元素的属性和值
                                $(".shang_payimg img").attr("src","${pageContext.request.contextPath}/e/images/"+dataid+"img.jpg");
                                //text() 方法方法设置文本内容。
                                $("#shang_pay_txt").text(dataid=="alipay"?"支付宝":"微信");
                        });
                        $("#btnClose").click(function(){
                                $(".shang_box").fadeToggle();
                        });

                        $.metadata.setType("attr","validate");
                        $("#chongzhiForm").validate();


                });

        </script>




</head>
<body>

<jsp:include page="head.jsp"></jsp:include>
<div class="fn-clear"></div>
<div class="wrap round-block">
        <div class="line-title">
                当前位置:<a href="${pageContext.request.contextPath}/e/index.jsp">首页</a> >> 账户余额
        </div>


        <div class="main">

                <jsp:include  page="menu.jsp"></jsp:include>
                <div class="main-content">


                        <div style="padding:30px;font-size:18px;">
                                当前账户余额<span style="font-size:24px;font-weight:800;color:#f00;">${sessionScope.huiyuan.yue}¥</span>

                                <a id="btnChongzhi" class="btn btn-danger"><i class="fa fa-money"></i>我要充值</a>

                        </div>

                        <div class="shang_box">
                                <form name="chongzhiForm"
                                          action="${pageContext.request.contextPath}/admin/huiyuanmanager.do"
                                          id="chongzhiForm" method="post">
                                        <a class="shang_close" href="javascript:void(0)" id="btnClose"
                                           title="关闭"><img src="${pageContext.request.contextPath}/e/images/close.jpg"
                                                                           alt="取消" /></a>

                                        <div class="shang_tit">
                                                <p> 充值金额:<input name="jine" style="width:80px" validate="{required:true,number:true,messages:{required:'请填写充值金额',number:'请填写正确充值金额'}}" type="text"id="txtJine" class="input-txt" />元</p>
                                        </div>
                                        <div class="shang_payimg">
                                                <img
                                                                src="${pageContext.request.contextPath}/e/images/alipayimg.jpg"
                                                                alt="扫码支持" title="扫一扫" />
                                        </div>
                                        <div class="pay_explain">扫码充值,充多少就多少</div>
                                        <div class="shang_payselect">
<%--                                                data-id只是行内存放数据的标签,等同于input中的value的作用--%>
                                                <div class="pay_item checked" data-id="alipay">
                                                        <span class="radiobox"></span> <span class="pay_logo"><img
                                                                src="${pageContext.request.contextPath}/e/images/alipay.jpg"
                                                                alt="支付宝" /></span>
                                                </div>
                                                <div class="pay_item" data-id="weipay">
                                                        <span class="radiobox"></span> <span class="pay_logo"><img
                                                                src="${pageContext.request.contextPath}/e/images/wechat.jpg"
                                                                alt="微信" /></span>
                                                </div>
                                        </div>不
                                        <div class="shang_info">
                                                <p>
                                                        打开<span id="shang_pay_txt">支付宝</span>扫一扫,即可进行充值
                                                </p>
                                        </div>
                                        <div>

                                                <input type="hidden" name="id" value="${sessionScope.huiyuan.id}" /> <input
                                                        type="hidden" name="actiontype" value="chongzhi" />
                                                <input type="hidden"
                                                           name="forwardurl" value="/e/huiyuan/chongzhiresult.jsp" /> <input
                                                        type="submit" value="充值" class="dashang">

                                        </div>

                                </form>

                        </div>





                </div>

        </div>

</div>


<div class="fn-clear"></div>


<jsp:include page="bottom.jsp"></jsp:include>



</body>
</html>

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

StoreDS 发表于 2022-4-20 20:33
$.metadata.setType("attr","validate");像是添加校验规则,比如validate="{required:true}"或者class="required".
$("#chongzhiForm").validate();应该就是对表单录入进行校验了
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-25 14:53

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表