Using HTML5 default value

Asked

Viewed 788 times

0

I am trying to bring a value to an input text disabled but the field is being shown as empty. I already removed the disabled and it keeps coming blank.

<input type="text" name="anterior" id="anterior" size="13" maxlength="50" disabled="disabled" value"123456,78" />

4 answers

5


1 - The attribute disabled is an attribute to indicate what its name says 'desabilitato', that is, he will not be skilled within form.

2 - Even with the attribute disabled, the value appears, in your case is not showing as the property 'value' is without the '=', just correct to:

value="123456,78"

3 - To have a non-enterable input that is accounted for by the form, use the attribute 'readonly', which also means the proper name 'read only', with this attribute the value of the field is not editable, but is skilled within the form.

Your correct input (If you want to submit the data via form) should be:

<input type="text" name="anterior" id="anterior" size="13" maxlength="50"  value="123456,78" readonly />

And another option (if you don’t want the data to be submitted via form) should be:

<input type="text" name="anterior" id="anterior" size="13" maxlength="50"  value="123456,78" disabled='disabled' />

4

Missed "=" after value.

Try it like this:

<input type="text" name="anterior" id="anterior" size="13" maxlength="50" disabled="disabled" value="123456,78" />

2

Missed equal sign in value. Change of value"123456,78" for value="123456,78".

2

Important The disabled is a disabled item, is not editable, and is not sent when sending forms. The best thing would be to use the readonly which is a reading element is just not editable, but is sent when the form according. And readonly you can focus etc, and disabled not.

Example of readonly: <input readonly type="text" name="anterior" id="anterior" size="13" maxlength="50" value="123456,78" />

  • 1

    Review your example, it seems to contrast with your explanation

  • I left my -1 because, in my view, the problem is not related to the fact that the field is disabled, as he put it in the answer. In it he hints that a field disabled cannot receive value and this makes no sense. The only problem in the question code is the absence of the equal in the attribute value.

  • Yes, I only commented for knowledge.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.