How to make a text input non-editable using jQuery ? Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report An HTML document containing the input text area and the task is to make the text input non-editable with the help of jQuery. There are two approaches that are discussed below: Approach 1:We are going to set the property readonly to true. To set the readonly property, we will use a prop() method. Example: HTML <!DOCTYPE HTML> <html> <head> <title> How to make a text input non-editable using JQuery? </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"> </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksForGeeks </h1> <p id="GFG_UP"></p> Type Here: <input id="input" /> <br><br> <button onclick="GFG_Fun()"> Click Here </button> <p id="GFG_DOWN"></p> <script> var el_up = document.getElementById('GFG_UP'); var el_down = document.getElementById('GFG_DOWN'); el_up.innerHTML = "Click on the button to " + "perform the operation."; function GFG_Fun() { $("#input").prop("readonly", true); el_down.innerHTML = "Input element is now read-only"; } </script> </body> </html> Output:Approach 2:We are going to set the property readonly to true. In this example, we will use attr() method to set the property value. Example: HTML <!DOCTYPE HTML> <html> <head> <title> How to make a text input non-editable using JQuery? </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"> </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksForGeeks </h1> <p id="GFG_UP"></p> Type Here: <input id="input" /> <br><br> <button onclick="GFG_Fun()"> Click Here </button> <p id="GFG_DOWN"></p> <script> var el_up = document.getElementById('GFG_UP'); var el_down = document.getElementById('GFG_DOWN'); el_up.innerHTML = "Click on the button to " + "perform the operation."; function GFG_Fun() { $("#input").attr("readonly", true); el_down.innerHTML = "Input element is now read-only"; } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to create a Disabled Input using jQuery Mobile ? P PranchalKatiyar Follow Improve Article Tags : JQuery CSS-Misc HTML-Misc jQuery-Misc Similar Reads How to Make Text Input Non-Editable using CSS? There are situations where you might want to create non-editable input fields. HTML and CSS both provide ways to achieve this.1. The read-only Attribute in HTMLThe read-only attribute in HTML is used to make a text input field non-editable, meaning users can see the content but cannot modify it. Thi 2 min read How to create a Text Input using jQuery Mobile ? jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be a Text Input using jQuery Mobile. Approach: First, we add the jQuery Mobile scripts needed for the project. <link rel=âstylesheetâ hre 1 min read How to create a Disabled Input using jQuery Mobile ? jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be creating a Disabled Input using jQuery Mobile. Approach: Add jQuery Mobile scripts needed for your project. <link rel=âstylesheetâ hre 1 min read How to make a Value/Text Input using jQuery Mobile ? jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be creating a Value/Text Input using jQuery Mobile. Approach: Add jQuery Mobile scripts needed for your project. <link rel=âstylesheetâ h 1 min read How to Disable Text Selection using jQuery? In this article, we are going to learn how to disable text Selection using jQuery. Disabling text selection refers to preventing users from highlighting or selecting text content on a webpage. Text seÂlection is a common feature in numerous web applications. However, there might arise situations whe 4 min read How to disable browser autofill on input fields using jQuery ? In this article, we will see how to disable the browser auto fill property on the input field. For that, HTML page is created in which jQuery CDN is imported to use jQuery and its code is written. Approach: Create a basic HTML page having at least one input field in it with the "id" attribute.Import 2 min read Like