A.JRJ
A.JRJ

Reputation: 361

Getting Value from disabled attribute in html

I had a form which can edit some parameters and some are disabled.While uploading the edited form the disabled parameters returned null value,my code is as follows,

<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> 

So while submitting the form ,should uses value "user.name" but it returns null since I provide disabled attribute.

Upvotes: 3

Views: 2931

Answers (2)

user2575725
user2575725

Reputation:

my requirement is it should be look like disabled but it should pass its value

You can use CSS to make it look disabled

.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>

Upvotes: 4

Rahul Pawar
Rahul Pawar

Reputation: 1036

Use only readonly instead of disabled

There is 2 choices :

<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  

Upvotes: 4

Related Questions