In HTML readonly attribute for input is (many times) defined as
<input readonly="readonly">
Some attributes play the role of boolean variables (e.g., the selected attribute for the OPTION element). Their appearance in the start tag of an element implies that the value of the attribute is "true". Their absence implies a value of "false".
Boolean attributes may legally take a single value: the name of the attribute itself (e.g., selected="selected").
Source : http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.3.4.2
So any value (or no value at all) used with readonly attribute will make the input read only.
So any value (or no value at all) used with readonly attribute will make the input read only.
Following declaration will make input as read only
<input readonly> // No value
<input readonly=""> //Empty string
<input readonly="readonly"> // LEGAL AND YOU SHOULD BE DOING THIS WAY
<input readonly="false"> // ANY string including false.
But in Spring <form:input> it should be either true of false
<form:input path="foo" readonly="true"> // input is read only
OR
OR
<form:input path="foo" readonly="false"> // input is no more read only
Same with disbled attribute, in HTML following syntax will make input as disabled
<input disabled> // No value
<input disabled=""> // Empty string
<input disabled="disabled"> // LEGAL AND YOU SHOULD BE DOING THIS WAY
<input disabled="false"> // ANY string including false.
while in Spring it should be either true or false
<form:input path="foo" disabled="true"> // input is disabled
OR
<form:input path="foo" disabled="false"> // input is no more disabled
Thanks for the post .. It is very helpful for me
ReplyDelete