【问题标题】:validation in jqgridjqgrid中的验证
【发布时间】:2010-01-05 09:11:09
【问题描述】:

我目前正在使用 ci 框架开发 jqgrid。只是想问一下jqgrid中的验证。我已经看到在 jqgrid 中可以像这样验证列:editrules: {required:true}} 等等......

这是我的问题,我想知道如果客户输入他/她想要的用户名但它已经存在,是否有可能。这可能使用 jqgrid 验证吗?

谢谢 -院长

【问题讨论】:

    标签: jquery jqgrid


    【解决方案1】:

    您可以使用custom edit rule 来完成此操作

    这是文档中的示例

    function mypricecheckforvalue(value, colname) {
    if (value < 0 || value >20) 
       return [false,"Please enter value between 0 and 20"];
    else 
       return [true,""];
    }
    jQuery("#grid_id").jqGrid({
    ...
       colModel: [ 
          ... 
          {name:'price', ..., editrules:{custom:true, custom_func:mypricecheckforvalue....}, editable:true },
          ...
       ]
    ...
    });
    

    【讨论】:

      【解决方案2】:

      这是我想出的解决方案

            {name:'actualNo',index:'actualNo',editable:true, edittype:"text", width:150,editoptions:{
                                      size: 15, maxlengh: 10,
                                      dataInit: function(element) {
                                          $(element).keyup(function(){
                                              var val1 = element.value;
                                              var num = new Number(val1);
                                              if(isNaN(num))
                                              {alert("Please enter a valid number");}
                                          })
                                      }
                                  }},
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-19
        • 1970-01-01
        • 2013-04-06
        • 2018-07-17
        • 2011-12-27
        相关资源
        最近更新 更多