Jquery jqgrid中的验证

Jquery jqgrid中的验证,jquery,jqgrid,Jquery,Jqgrid,我目前正在使用ci框架开发jqgrid。只想问一下jqgrid中的验证。我已经看到,在jqgrid中,可以像这样验证列:editrules:{required:true}},等等 这里是我的问题,我想知道如果一个客户输入了他/她想要的用户名,但它已经存在,这是否可能。这是否可以使用jqgrid验证 谢谢 -Dean您可以使用 这是文档中的示例 function mypricecheckforvalue(value, colname) { if (value < 0 || value >

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

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

谢谢 -Dean

您可以使用

这是文档中的示例

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 },
      ...
   ]
...
});
函数mypricecheckforvalue(值,colname){
如果(值<0 | |值>20)
返回[false,“请输入介于0和20”之间的值];
其他的
返回[真,“];
}
jQuery(“网格id”).jqGrid({
...
colModel:[
... 
{name:'price',…,editrules:{custom:true,custom_func:mypricecheckforvalue..},editable:true},
...
]
...
});

我想出了一个解决方案

      {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");}
                                    })
                                }
                            }},