Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery数字键盘输入问题_Jquery - Fatal编程技术网

Jquery数字键盘输入问题

Jquery数字键盘输入问题,jquery,Jquery,我试图在javascript数字键盘中输入逗号。请参阅下面的代码 /*! * JQFNumKeypad * http://www.jqueryfun.com/ */ (function($) { $.fn.JQFNumKeypad = function(options) { // Defaults var defaults = { fadeSpeed: 400, clearText: 'Clear' }; // Extend op

我试图在javascript数字键盘中输入逗号。请参阅下面的代码

 /*!
* JQFNumKeypad
* http://www.jqueryfun.com/
*/
(function($) {
  $.fn.JQFNumKeypad = function(options) {

    // Defaults
    var defaults = {
      fadeSpeed: 400,
      clearText: 'Clear'
    };

    // Extend options
    var options = $.extend(defaults, options);

    // Show keypad on document click / Focus First
    $(document).click(function() {$('.jqfnumkeypad').show();});
    $(document).ready(function(){$('input').first().focus();});

    // Loop each instance
    return this.each(function() {

      // Instance
      var instance = $(this);

      // Keypad layout
      var keypad = '<div id="jqfnumkeypad_' + instance.attr('name') + '" class="jqfnumkeypad"><div class="jqfnumkeypad_keypad"><table width="100%" cellpadding="0" cellspacing="0">';
      for(var i = 1; i <= 9; i++) {
        if((i-1)%3 == 0) keypad += '<tr>';
        keypad += '<td class="jqfnumkeypad_digit">' + i + '</td>';
        if(i%3 == 0) keypad += '</tr>';
      }
      keypad += '<tr><td class="jqfnumkeypad_digit">0</td><td class="jqfnumkeypad_clear">' + options.clearText + '</td><td class="jqfnumkeypad_coma">,</td></tr></table></div></div>';
      $(keypad).insertAfter(instance).css({right: 0, top: instance.position().top});

      // Prevent hide on click
      instance.click(function(e) {e.stopPropagation();});

      // Define on focus event
      instance.focus(function() {
        $('#jqfnumkeypad_' + instance.attr('name')).css('z-index', '99').fadeIn(options.fadeSpeed, function() {
          // Digit click
          $('#jqfnumkeypad_' + instance.attr('name') + ' .jqfnumkeypad_digit').unbind().bind('click', function(e) {
          if(instance.attr('maxlength') == -1 || instance.val().length < instance.attr('maxlength')) instance.val(instance.val() + parseFloat($(this).html()));
            e.stopPropagation();
          });
          // Clear click
          $('#jqfnumkeypad_' + instance.attr('name') + ' .jqfnumkeypad_clear').unbind().bind('click', function(e) {
            instance.val('');
            e.stopPropagation();
          });
          // Coma click
          $('#jqfnumkeypad_' + instance.attr('name') + ' .jqfnumkeypad_coma').unbind().bind('click', function(e) {
            if(instance.attr('maxlength') == -1 || instance.val().length < instance.attr('maxlength')) instance.val(instance.val() + $(this).html());
            e.stopPropagation();
          });

        }).siblings('div').css('z-index', '0');
        // Blur to prevent instance events
        instance.blur();
      });
    });
  }
})(jQuery);
有人能帮我解决这个问题吗? 当前,当您按下逗号按钮时,它将清除输入字段。
我需要逗号,因为需要的输入是欧洲货币格式的,为什么不在输入字段上为jQuery使用屏蔽输入插件呢


这样,您就不必让用户输入,您仍然可以获得所需的格式。

您在调试方面做了哪些尝试?单击逗号时,是否调用其单击事件处理程序?如果是,instance.attr'maxlength'返回的值是多少?