Search code examples
javascripthtmltextinputonblur

Cannot read full text in input if it has property onfocus="this.blur()


Cannot use mouse or keyboard to read the text after Trial2. Input box just displays text till Trial 2 and then cannot scroll further. This happens after putting blur() property. I want the user to be able to read the full text, as well keep the blur property as it is doing some validations.

<input type="text" id="mybox" value="This is trial1 This is trial2 This is trial3" onfocus="this.blur()"/>

Solution

  • This solved my question ! @Rancho thanks for the idea!

    $("#txtUSLead").on("mouseover", function () {
    if ((this.value.length) > 25)
    {
    $('#txtUSLead').css('width', ((this.value.length + 1) * 7) + 'px');
    }       
    });
    $("#txtUSLead").on("mouseout", function () { $('#txtUSLead').css('width', 180); })