Open In App
Related Articles

HTML oninput Event Attribute

Improve Article
Save Article
Like Article

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 occurs immediately when the value of the element changes while the onchange attribute occurs when the element loses Focus. The other difference is that onchange attribute also works with the <select> element.

Supported Tags:

  • <input type=”password”>
  • <input type=”search”>
  • <input type=”text”> 
  • <textarea>


<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>.



<!DOCTYPE html>
    <title>oninput attribute</title>
        body {
            text-align: center;
        h1 {
            color: green;
    <h2>oninput Attribute</h2>
    Enter some Text here: <input type="text"
    <p id="sudo"></p>
        function Geeks() {
            let x = document.getElementById("GFG").value;
            document.getElementById("sudo").innerHTML =
                "Entered Text: " + x;


Supported Browsers: The browser supported by oninput event attribute are listed below:  

  • Apple Safari 3.1
  • Google Chrome 1
  • Edge 79
  • Firefox 6
  • Opera 11.6
  • Internet Explorer 9


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 04 Aug, 2023
Like Article
Save Article
Similar Reads
Related Tutorials