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

  • 相关阅读:
    通过反射实现IOC功能
    数据访问模式之Repository模式
    .NET自带IOC容器MEF之初体验
    权限管理系统进入关键的开发阶段
    待销售分拣单App数据推送
    做一个自己的权限管理系统
    linux tar 命令 --致力于“一眼看懂,随手就用”的随笔
    python 简单实现文件拷贝
    实验比较python中的range和xrange
    安装 chardet ,出现ImportError: No module named setuptools
  • 原文地址:https://www.cnblogs.com/OP-RONG/p/4203906.html
Copyright © 2011-2022 走看看