如何在该代码中使文本框只读


How can I make a textbox readonly in this code

<label class="control-label" for="inputEmail">First Name:</label>
<div class="controls">
<input type="text" class="span4" id="inputEmail" name="firstname"  value="<?php echo $row['firstname']; ?>" placeholder="First Name" required>
<input type="hidden" id="inputEmail" name="id" value="<?php echo $get_id;  ?>" placeholder="First Name" required>     

如果要使文本字段只读,请使用readonly属性。

示例:

<input type="text"value="foo"readonly>

从您的代码

<label class="control-label" for="inputEmail">First Name:</label>
<div class="controls">
<input type="text" class="span4" id="inputEmail" name="firstname"  value="<?php echo $row['firstname']; ?>" placeholder="First Name"readonly>
<input type="hidden" id="inputEmail" name="id" value="<?php echo $get_id;  ?>" placeholder="First Name" readonly>     

如果你想让inputEmail成为只读字段,你可以使用

<label class="control-label" for="inputEmail">First Name:</label>
<div class="controls">
<input type="text" class="span4" id="inputEmail" name="firstname"  value="<?php echo $row['firstname']; ?>" placeholder="First Name" required readonly>
<input type="hidden" id="inputEmail" name="id" value="<?php echo $get_id;  ?>" placeholder="First Name" required>  

请注意,我在第3行的输入标记末尾添加了readonly。