Question

How do I set the readonly attribute of a TextField instance in javascript without using document.getElementById("myText").readOnly...

How do I set the readonly attribute of a TextField instance in javascript without using document.getElementById("myText").readOnly = true;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

A textfield can be made readonly by specifying the "readonly" attribute
of the <input> tag.

For Example: <input type="text" name="text2" value=" " readonly>

we cannot modify the read-only input field.

sample HTML code:

<!DOCTYPE html>

<html>
    <head>
        <title>Non-editable textfield</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
         <form>
      
        <!-- editable textfield -->          
        Editable Field: <input type="text" name="text1" value=""><br><br>
      
        <!-- Non-editable textfield -->
        Non-editable Field: <input type="text" name="text2" value="" readonly> <br><br>

      
        <input type="submit" value="Submit">
      
        </form>
      
    </body>
</html>

SCREENSHOT FOR OUTPUT:

Editable Field: hello Non-editable Field: Submit

Add a comment
Know the answer?
Add Answer to:
How do I set the readonly attribute of a TextField instance in javascript without using document.getElementById("myText").readOnly...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I have some code for HTML/Javascript but I need to change it up a bit. Heres...

    I have some code for HTML/Javascript but I need to change it up a bit. Heres the assignment and what I have. The part in the bold is what I need help with. I need a button called new timer for when it reaches zero... Thank you. Assignment For this assignment, you will write a timer application in HTML and JavaScript. Your HTML document should contain the following elements/features: HTML tags: An <input> tag labeled "Timer Duration" with the initial...

  • How do I set a column attribute with value from another table? I have this manager_specialisation table: CREATE TABLE ma...

    How do I set a column attribute with value from another table? I have this manager_specialisation table: CREATE TABLE manager_specialisation ( specialisation_id NUMBER(4) NOT NULL, specialisation_type VARCHAR(50) NOT NULL ); And I want to update a column in my garage_manager table like this except the specialisation_id is WHERE specialisation_type = 'S'.? UPDATE garage_manager SET specialisation_id=manager_specialisation.specialisation_id WHERE man_id=1 AND garage_email= (SELECT garage_code FROM garage WHERE garage_email = '[email protected]') ;

  • 1. Buttons that can automatically be created using the type attribute are __________. A. submit B....

    1. Buttons that can automatically be created using the type attribute are __________. A. submit B. reset C. submit and reset D. All buttons require the type attribute. 2. Which of the following are ways to submit form data? A. email B. to a server C. to a JavaScript program D. All of these are ways to submit form data. 3. When using a set of radio buttons, which attribute must be the same for all buttons in the set?...

  • 1.JavaScript scripts can be embedded in an HTML page using the ______ tag. 2.True or false:...

    1.JavaScript scripts can be embedded in an HTML page using the ______ tag. 2.True or false: Dreamweaver’s built-in behaviors require HTML5 structural elements such as <nav> and <section>. 3.Elements must have a defined ___ attribute to be targeted by Dreamweaver’s behaviors 4.The _____________ behavior allows image files to load before they are actually called by a behavior such as Swap Image. 5.Scripts attached to the _______ tag are executed as soon as they browser loads the page. 6.In JavaScript, a(n)...

  • How can I this to jquery instead of it being javascript? function showMssg() { var message...

    How can I this to jquery instead of it being javascript? function showMssg() { var message = document.getElementsByTagName('pre')[0]; var console = document.getElementById('console'); if (message.style.display == 'block') { log += ' The log is now hidden. '; message.style.display = 'none'; console.innerHTML = 'Show Console Log'; } else { log += ' The log is now visible. '; message.innerHTML = log; message.style.display = 'block'; console.innerHTML = 'Hide Console Log'; } }

  • Create a two-page website by using HTML commands (without using CSS or javascript).

    Create a two-page website by using HTML commands (without using CSS or javascript).

  • I am trying to create a slide show using JavaScript. This is what I have so...

    I am trying to create a slide show using JavaScript. This is what I have so far: HTML: <!DOCTYPE html> <html lang="en"> <head>    <meta charset="utf-8"> <title>Slide Show</title> <link rel="stylesheet" href="main.css"> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <script src="slide_show.js"></script> </head> <body> <section> <h1>Fishing Slide Show</h1> <ul id="image_list"> <li><a href="images/casting1.jpg" title="Casting on the Upper Kings"></a></li> <li><a href="images/casting2.jpg" title="Casting on the Lower Kings"></a></li> <li><a href="images/catchrelease.jpg" title="Catch and Release on the Big Horn"></a></li> <li><a href="images/fish.jpg" title="Catching on the South Fork"></a></li> <li><a href="images/lures.jpg" title="The Lures for Catching"></a></li> </ul>...

  • How do I write a JavaScript program that prints a welcome message in a large blue...

    How do I write a JavaScript program that prints a welcome message in a large blue font?

  • NEED HELP with HTML with Javascript embedding for form validation project below. I have my code...

    NEED HELP with HTML with Javascript embedding for form validation project below. I have my code below but I'm stuck with validation. If anyone can fix it, I'd really appreciate. ****************************************************************************** CODE: <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>Nice</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var textFromTextArea; function getWords(){ var text =...

  • I created an Html with tabs, then how do I import the constant character content of...

    I created an Html with tabs, then how do I import the constant character content of a JS into one of these tabs without editing that JS file? here is my page: <!DOCTYPE html> <html> <body>     <div id="main">         <span class="tab">             <button class="current">News</button>             <button>Create</button>             <button onclick="about()">About</button>             <button>Login</button>         </span>         <div class="con" style="display: block"> For news content</div>         <div class="con">For create content</div>         <div class="con" id="about">For about content</div>     </div> </body> <script type="text/javascript" src='strings.js'></script> <script>     var box = document.getElementById('main');     var btns = document.getElementsByTagName('button');     var divs =...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT