zoukankan      html  css  js  c++  java
  • 簡單的validate驗證

    $(function(){
    $("#myform").validate({
    rules:{
    code:{required:true,remote: "<%=request.getContextPath()%>/Payment/CheckExisted",minlength:4},//minlength最小值,下面的鼠標點擊事件加的0000不能大於此值

    },
    messages:{
    code:{required:"請輸入編號",remote:jQuery.validator.format("此编号已被使用"),minlength:"請输入編號"},


    }
    });
    $("#code").blur(function(){
    if( $.trim($(this).val())=='') return;
    var val ="0000"+$(this).val();
    val = val.substr(val.length-4,4);
    $(this).val(val);
    $(this).keyup();
    });

    $("#freeDef,#maxAmt,#code").onlypressnum();

    if ($(".interval_tip").length > 0) {
    setTimeout(function() {
    $(".interval_tip").fadeOut();
    }, 5000);
    }
    /* parent.$('#dg').datagrid('reload'); */
    });

    ////CouponController裡的函數//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    @RequestMapping(value="Coupon/CheckExisted",method=RequestMethod.POST)
    public void CheckExisted(Coupon coupon,HttpServletResponse response,@RequestParam("code") String code){
    try {
    String res="false";
    if(null!=code){
    String codee ="00000000" +code.trim();
    String codeee=codee.substring(code.length());
    /*System.out.println(codee+"@@@@"+codee.length());*/

    System.out.println(codeee);
    Coupon ks = CouponService.getCouponById(codeee);
    if(null==ks)
    res="true";
    }
    response.setHeader("Content-type", "text/json;charset=UTF-8");
    // 如果是默認繁體中文查看,則設置為UTF-8.
    response.setCharacterEncoding("UTF-8");
    response.getWriter().write(res);
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }

  • 相关阅读:
    JavaScrip 数组/字典/循环
    初识javaScript
    css内容补充之其它
    position
    css的存在形式
    CSS选择器
    Html的Head内标签
    Linux设置FQDN
    saltstack 全面介绍
    jQuery文档处理
  • 原文地址:https://www.cnblogs.com/OP-RONG/p/4203906.html
Copyright © 2011-2022 走看看