Home  >  Article  >  Web Front-end  >  How to set form read-only in javascript

How to set form read-only in javascript

藏色散人
藏色散人Original
2021-06-30 09:09:593270browse

How to set read-only form in javascript: 1. Set by "onfocus=this.blur()" method; 2. Set by readonly; 3. Set by disabled.

How to set form read-only in javascript

The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.

How to set the form read-only in javascript?

Javascript: How to make the form text box read-only and non-editable

Sometimes, we want the text box in the form to be read-only so that the user cannot modify the information in it, such as using The content of 27f99ac88de2effeb81280b6bf4887ac, the word "China" cannot be modified. To summarize, the implementation methods are as follows.

Method 1: onfocus=this.blur()

<input type="text" name="input1" value="中国" onfocus=this.blur()>

Method 2: readonly

<input type="text" name="input1" value="中国" readonly>
<input type="text" name="input1" value="中国" readonly="true">

Method 3: disabled

<input type="text" name="input1" value="中国" disabled>

[Related recommendations:javascript advanced tutorial

The above is the detailed content of How to set form read-only in javascript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn