How to get text of an input text box during onKeyPress?

前端 未结 12 1645
遥遥无期
遥遥无期 2020-11-28 05:12

I am trying to get the text in a text box as the user types in it (jsfiddle playground):

12条回答
  •  感动是毒
    2020-11-28 05:55

    By using event.key we can get values prior entry into HTML Input Text Box. Here is the code.

    function checkText()
    {
      console.log("Value Entered which was prevented was - " + event.key);
      
      //Following will prevent displaying value on textbox
      //You need to use your validation functions here and return value true or false.
      return false;
    }

提交回复
热议问题