Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid allows only numbers when editing cell

Tags:

jqgrid

I want to prevent my user from typing letters inside a numeric field. I saw that there is an option of: editrules:{number:true}, but this option will let the user click any key the user wants and only when row saved it will alert for illegal input. This is not good option for me. I want to prevent from the start the typing of keys that are not numbers (for example in a regular input I can use jQuery's .numeric()).

How can this be done?

like image 858
user590586 Avatar asked Jan 20 '23 11:01

user590586


1 Answers

      {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");}
                                    })
                                }
                            }},
like image 190
shah sanket Avatar answered Jan 29 '23 11:01

shah sanket