validation in jqgrid
Asked Answered
G

2

8

im currently working on jqgrid using ci framework. just want to ask about the validation in jqgrid. I've seen that in jqgrid a column can be validated like this: editrules: {required:true}}, and so on...

heres my question, i want to know if its possible that if a client enters his/her desired username but it already exist. Is this possible using the jqgrid validations?

thanks -Dean

Grannias answered 5/1, 2010 at 9:11 Comment(0)
V
10

You can do this using a custom edit rule

This is the example in the documentation

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 },
      ...
   ]
...
});
Vienne answered 7/1, 2010 at 16:25 Comment(0)
T
1

Here is a solution I figured out

      {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");}
                                    })
                                }
                            }},
Transgress answered 23/11, 2012 at 6:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.