HTML | oninput Event Attribute
This attribute works when it gets user input value. This attribute mainly fires when the user change the value of <input> and <textarea> element. This attribute is quite similar to onchange attribute but the basic difference is that the oninput event attribute occure immediately when the value of element changes while the onchange attribute occurs when the element loses Focus. The other difference is that onchange attribute also works with <select> element.
Syntax:
<element oninput = "script">
Attribute Value: This attribute contains value script and it works when oninput event triggered. This attribute is supported by many HTML tags: <input type=”password”>, <input type=”search”, <input type=”text”> and <textarea>.
Example:
<!DOCTYPE html> <html> <head> <title>oninput attribute</title> <style> body { text-align:center; } h1 { color:green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>oninput Attribute</h2> Enter some Text here: <input type="text" id="GFG" oninput="Geeks()"> <p id="sudo"></p> <script> function Geeks() { var x = document.getElementById("GFG").value; document.getElementById("sudo").innerHTML = "Entered Text: " + x; } </script> </body> </html> |
Output:

Supported Browsers: The browser supported by oninput event attribute are listed below:
- Apple Safari 5.0
- Google Chrome
- Firefox 4.0
- Opera
- Internet Explorer 9.0
Recommended Posts:
- HTML | onpaste Event Attribute
- HTML | onmouseover Event Attribute
- HTML | onkeydown Event Attribute
- HTML | onoffline Event Attribute
- HTML | onsubmit Event Attribute
- HTML | onfocus Event Attribute
- HTML | oncontextmenu Event Attribute
- HTML | onload Event Attribute
- HTML | onmousemove Event Attribute
- HTML | onmouseup Event Attribute
- HTML | onwheel Event Attribute
- HTML | onselect Event Attribute
- HTML | ondragend Event Attribute
- HTML | ondrag Event Attribute
- HTML | ontoggle Event Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



