繁体   English   中英

从HTML中的禁用属性获取价值

[英]Getting Value from disabled attribute in html

我有一个可以编辑某些参数而有些被禁用的表单。在上传已编辑的表单时,禁用的参数返回空值,我的代码如下,

<div class="form-group col-md-6">
      <label class="control-label required"  for="name">Name</label>
      <input type="text" readonly="readonly" disabled value="{user.name}}">
</div> 

因此,在提交表单时,应使用值“ user.name”,但由于我提供了disable属性,它返回null。

我的要求是应该看起来像已禁用,但应该通过其值

您可以使用CSS使其处于禁用状态

 .disabled { background: #ccc; cursor: not-allowed; border-width: 1px; } 
 <input type="text" readonly="readonly" class="disabled" /> <input type="password" readonly="readonly" class="disabled" /> <textarea readonly="readonly" class="disabled"></textarea> 

仅使用readonly而不是disabled

有2个选择:

<input type="text" value="{{user.name}}" readonly>
// In this case you can get post values  

<input type="text" value="{{user.name}}" disabled>
// In this case you can not get post values  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM