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.
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.
Share Improve this question asked Aug 23, 2018 at 6:13 A.JRJA.JRJ 3711 gold badge6 silver badges17 bronze badges 3-
If you mark it as
disabled
then it won't pass along its value. Perhaps you can mark it asreadonly
if that fits your requirement? – Mohit Bhardwaj Commented Aug 23, 2018 at 6:19 -
@MohitBhardwaj Using readonly make the parameter similar to other where editing cursor is there but cant'edit.but my requirement is it should be look like
disabled
but it should pass its value – A.JRJ Commented Aug 23, 2018 at 6:24 -
1
how about using js to enable them just before sending ? you should be able to do it overiding
form.onsubmit
– jonatjano Commented Aug 23, 2018 at 6:27
2 Answers
Reset to default 5Use 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
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>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742242598a4407317.html
评论列表(0条)