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();
    }
    }

  • 相关阅读:
    HBase Flush 机制
    HBase 预分区 & Phoenix 加盐
    Phoenix 索引
    python 列表、元组、字典、集合的比较操作
    Redis HA
    基于 Redis 和 ZooKeeper 的分布式锁
    Ubuntu 系统设置 Swappiness 值
    Ubuntu_16.04 安装 Pyhon3.6
    Win10创意者更新秋季版升级常见问题解决方案
    如何使用注册表在Win10中调整屏幕亮度
  • 原文地址:https://www.cnblogs.com/OP-RONG/p/4203906.html
Copyright © 2011-2022 走看看