Skip to content Skip to sidebar Skip to footer

Html Text Box Form That Will Not Allow Input

Is there any class in an html form that does not allow you to input or change the value in that text box. But you can see its content , for example the code below will allow you to

Solution 1:

What about the readonly attribute?

<input type="text" name="telnum" value="123456" readonly="readonly" />

Solution 2:

You can put readonly="readonly" in your <input> tag. You can also use disabled="disabled". Both provide varying degrees of "disabled-ness" as demonstrated here.

This is not fail-safe, though. Make sure that you do check when the form is POSTed back if the value has been modified - someone can craft a valid POST request with the field value modified - there's nothing you can do about that except check on the server-side if it's been modified from what it was originally.


Solution 3:

If you don't want it edited, and if there's no reason for it ever to be edited, then it shouldn't be in an input element at all. Just echo it as normal text.


Solution 4:

You can try "disabled" OR "readonly"

<form> 
  <label for="disabled">Disabled</label><br> 
  <input name="disabled" value="disabled" disabled>
  <br><br>
  <label for="readonly">Read Only</label><br> 
  <input name="readonly" value="readonly" readonly> 
</form>

Solution 5:


Post a Comment for "Html Text Box Form That Will Not Allow Input"