Javascript change event on input element fires on only losing focus

前端 未结 7 2142
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-27 15:45

I have an input element and I want to keep checking the length of the contents and whenever the length becomes equal to a particular size, I want to enable the submit button

相关标签:
7条回答
  • 2020-11-27 16:20

    It took me 30 minutes to find it, but this is working in June 2019.

    <input type="text" id="myInput" oninput="myFunction()">
    

    and if you want to add an event listener programmatically in js

    inputElement.addEventListener("input", event => {})
    
    0 讨论(0)
提交回复
热议问题