How To Set Readonly Attribute

Table of contents:

How To Set Readonly Attribute
How To Set Readonly Attribute

Video: How To Set Readonly Attribute

Video: How To Set Readonly Attribute
Video: How to Add and Remove Readonly Attribute in Javascript 2024, May
Anonim

The ReadOnly attribute means that the object to which it belongs cannot be changed by an unauthorized user. For example, if you apply it to a file stored on the hard disk of a personal computer, the user or application program will be able to read its contents, but will not be able to make any changes. This attribute can be applied not only to files, but also, say, to fields of some form in a hypertext document.

How to set readonly attribute
How to set readonly attribute

Instructions

Step 1

If you want to prohibit changing a file on one of your computer's media, then the easiest way to do this is using the file manager. In the most common Windows operating system today, this application is called "Explorer" and can be launched using the hotkey Win + E or by double-clicking on the "My Computer" icon on the desktop. In addition to these methods, you can activate it by using the "Computer" item in the OS main menu, which is opened by clicking on the "Start" button.

Step 2

Using the directory tree located on the right side of the Explorer interface, navigate to the folder containing the file you need, find it and right-click. In the pop-up context menu, the bottom line will be called "Properties" - select this menu item.

Step 3

A checkbox will be placed in the "Attributes" line on the "General" tab of the opened window, to which the inscription "Read Only" is associated - this setting corresponds to the English language Read Only. Check this box and click OK. This completes the procedure for setting the ReadOnly attribute to the selected file.

Step 4

If you want to make any field of a form placed in a hypertext document unavailable for editing, you should add an attribute with the ReadOnly value to the corresponding tag. To do this, open the HTML source of the page and find the tag for the required form field. Such a tag, for example, for a text field might look like this:

Step 5

Add an additional readonly attribute to the tag and assign it the same value ("readonly"). An example from the previous step after such editing should look like this: As a result, the text in this field will become unavailable for changes. This attribute can be applied to other form elements, for example, to the multi-line textarea: Do not touch with your hands!

Recommended: