【问题标题】:how can i validate in jqgrid我如何在 jqgrid 中进行验证
【发布时间】:2018-07-17 00:16:59
【问题描述】:

如何使我的保存按钮仅在验证字段为数字时才保存,如果不是,则显示消息?

{ name: 'fechaHoraRegistro', index: 'fechaHoraRegistro', width: 90, editable: true, editoptions: {
            size: 15, maxlengh: 10,
                dataInit: function (es) {
                    $(es).datepicker({ dateFormat: 'dd-mm-yy' });                            
                },
            }
        },
        {
            name: 'horaRegistro', index: 'horaRegistro', width: 0, editable: true, hidden: false, edittype: 'text', editoptions: {
                size: 15, maxlengh: 10,
                dataInit: function (element) {
                    $(element).keyup(function () {
                        var val1 = element.value;
                        var num = new Number(val1);
                        if (isNaN(num))
                        { alert("Ingresar solo numeros"); }
                    })
                }
            }
        },

【问题讨论】:

    标签: jquery jqgrid jqgrid-asp.net mvcjqgrid


    【解决方案1】:

    您可以使用内置验证。为此,您将需要使用编辑规则。您可以在Guriddo jqGrid documentation. 中找到更多信息

    在你的情况下很简单:

    {
        name: 'horaRegistro', index: 'horaRegistro', width: 0, editable: true, hidden: false, 
        edittype: 'text', 
        editoptions: {
            size: 15, 
            maxlengh: 10,
        },
        editrules : { 
           number : true
        }
    },
    

    您还可以设置最小最大和其他限制。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-16
      • 1970-01-01
      • 2018-05-11
      • 2014-05-20
      • 2021-12-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多