Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html text box form that will not allow input

Tags:

html

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 see the content of the record in mysql database. But what I want is for it not to be edited. What would I add to the code below so that its content will not be editted by the users:

   <tr>
<td><font size="3">Civil Status</td>
<td>:</td>
<td><input name="cs" type="text" maxlength="7" value="<?php echo $row["CSTAT"]; ?>"></td>
<td><font size="3">Age</td>
<td>:</td>
<td><input name="age" type="text" maxlength="3" value="<?php echo $row["AGE"]; ?>"></td>
<td><font size="3">Birthday</td>
<td>:</td>
<td><input name="bday" type="text" maxlength="12" value="<?php echo $row["BDAY"]; ?>"></td>

</tr>

<tr>
<td><font size="3">Address</td>
<td>:</td>
<td><input name="ad" type="text" maxlength="25" value="<?php echo $row["ADDRESS"]; ?>"></td>
<td><font size="3">Telephone #</td>
<td>:</td>
<td><input name="telnum" type="text" maxlength="11" value="<?php echo $row["TELNUM"]; ?>"></td>

<td width="23"><font size="3">Sex</td>
<td width="3">:</td>
<td width="174"><input name="sex" type="text"  maxlength="1" value="<?php echo $row["SEX"]; ?>"></td>
</tr>
like image 571
user225269 Avatar asked Mar 01 '10 11:03

user225269


People also ask

How do I prevent user input in a text box?

Setting the onkeydown attribute to return false makes the input ignore user keypresses on it, thus preventing them from changing or affecting the value.

How do I restrict text input in HTML?

The HTML <input> tag is used to get user input in HTML. To give a limit to the input field, use the min and max attributes, which is to specify a maximum and minimum value for an input field respectively. To limit the number of characters, use the maxlength attribute.

How do I make a textbox non editable in HTML?

The readonly attribute makes a form control non-editable (or “read only”). A read-only field can't be modified, but, unlike disabled , you can tab into it, highlight it, and copy its contents. Setting the value to null does not remove the effects of the attribute. Instead use removeAttribute('readonly') .

How do I make my input box non editable?

You can use readonly attribute, if you want your input only to be read. And you can use disabled attribute, if you want input to be shown, but totally disabled (even processing languages like PHP wont be able to read those). When you send form to a php file, it won't read disabled inputs. It may be what he meant.


1 Answers

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>
like image 80
Nikhil Mahirrao Avatar answered Dec 18 '22 07:12

Nikhil Mahirrao