cursor is jumping when pressing the arrow keys

前端 未结 5 971
日久生厌
日久生厌 2021-01-07 14:26

I have a textbox, where a forbidden character cant be typed. #.

This works, however, when the textbox is filled in with data, and I put the focus on the middle of th

5条回答
  •  情深已故
    2021-01-07 14:54

    This is a bit unpleasant, and I'm not 100% happy, but it solves all the given issues that you've had...

    $("[id$=txtClient]").keyup(function (e) {
        var text = $(this).val();
        if (text.indexOf("#") > -1) {
            text = text.replace("#", "");
            $(this).val(text);
        }
    });
    

    Here's a jsFiddle example...

    http://jsfiddle.net/E4cBK/

提交回复
热议问题