Javascript Error in FireFox Not in IE and Chrome

后端 未结 1 1362
礼貌的吻别
礼貌的吻别 2020-12-21 23:01

I use the following function for decimal validation.the textbox only allow to enter numbers and .(dot) symbol only.It was working fine in IE and Chrome.My problem is I get <

相关标签:
1条回答
  • 2020-12-21 23:50

    In firefox, event isn't global. window.event is undefined. You need to pass the event as a parameter. And by the way, you should use .on instead of .live if you use jQuery >= 1.7.

    $('.decimalValidate').live('keypress', function (e) {
        var decimalid = $(this).attr("id");
        var decimalval = $('#' + decimalid).val();
        var decimalvalidate = ApplyDecimalFilter(decimalval, e);
        if (decimalvalidate == false) return false;
    });
    
    function ApplyDecimalFilter(id, event) {
        try {
            return NewDecimalFilter(id, event);
    
        } catch (e) {
            alert(e.message);
        }
    }
    

    The live demo.

    0 讨论(0)
提交回复
热议问题