Failed to execute 'setSelectionRange' on 'HTMLInputElement'

jcubic commented on 7 Jan 2016

When I use number input I've got error in Google Chrome

Uncaught InvalidStateError: Failed to execute 'setSelectionRange' on 'HTMLInputElement': 
The input element's type ('number') does not support selection.
@jcubic
 

jcubic commented on 7 Jan 2016

The fix will be something like:

        activate: function() {
            if(this.$input.is(':visible')) {
                this.$input.focus();
                var type = this.$input.attr('type');
                if (type && type.match(/^(text|search|password|tel|url)$/i) || !type) {
                    $.fn.editableutils.setCursorPosition(this.$input.get(0), this.$input.val().length);
                }
                if(this.toggleClear) {
                    this.toggleClear();
                }
            }
        },
@zorosun
 

zorosun commented on 1 Aug 2016

@akakoori you might want to look at this

Pull request

I fixed it by inserting

  (function() {
      var original = $.fn.editableutils.setCursorPosition;
      $.fn.editableutils.setCursorPosition = function() {
          try {
              original.apply(this, Array.prototype.slice.call(arguments));
          } catch (e) { /* noop */ }
      };
  })();
可以改用type='text',就不会出现这个样子
当然,你也可以 
  
min= "0"
相关推荐
©️2020 CSDN 皮肤主题: 酷酷鲨 设计师:CSDN官方博客 返回首页