0

I am creating timpicker plugin, here is what i have so far.

HTML

 <input id="txtTime"/>

jQuery:

 function formatTime(s) {
        return s.replace(/\D/g, "").replace(/^(\d\d)(\d\d).*$/, "$1:$2")
    }

    (function ($) {
        $.fn.timeInput = function () {
            return $(this).keyup(function () {
                $(this).val(formatTime($(this).val()))
            });
        }
    })(jQuery);

    $("#txtTime").timeInput()

Problem: I am using chrome 28 and in that Cursor always goes to the end of text. if i use change(), it works fine. Can anybody help me to resolve this issue? or why this is happening? in firefox it works fine.

Fiddle Demo

Any help is greatly appreciated. Thank you

Dhaval Marthak
  • 17,246
  • 6
  • 46
  • 68

0 Answers0