I want to disable a <form:input>
with the attribute disabled, but it's not working.
<td class="value">
<sec:authorize access="hasAnyRole('ROLE_EDIT_DEVICE_INSTALL_DATE')">
<form:input path="installDt" maxlength="10" size="10" cssClass="installDatePicker" />
<form:errors path="installDt" cssClass="errormsg" />
</sec:authorize>
<sec:authorize access="!hasAnyRole('ROLE_EDIT_DEVICE_INSTALL_DATE')">
<form:input path="installDt" maxlength="10" size="10" cssClass="installDatePicker" disabled="disabled" />
<form:errors path="installDt" cssClass="errormsg" />
</sec:authorize>
</td>
Does anybody have any idea to solve it ?
This application needs more than raw HTML. The Spring Initializr created an application class for you. The following listing (from src/main/java/com/example/validatingforminput/ValidatingFormInputApplication.java) shows that class: To activate Spring MVC, you would normally add @EnableWebMvc to the Application class.
Definition and Usage. When present, it specifies that the <input> element should be disabled. A disabled input element is unusable and un-clickable. The disabled attribute can be set to keep a user from using the <input> element until some other condition has been met (like selecting a checkbox, etc.).
When the page is loaded, the input fields are populated by Spring, which calls the getter of each field bound to an input field. When the form is submitted, the setters are called to save the values of the form to the object.
A disabled input element is unusable and un-clickable. The disabled attribute can be set to keep a user from using the <input> element until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the <input> element usable.
To disable it, use disabled=true
. It accepts true|false.
<form:input path="installDt" maxlength="10" size="10" cssClass="installDatePicker" disabled="true" />
When I try to do input disable with disabled="true"
, the data is null at core code, but when I try it with readonly, it did this properly.
Try readonly="readonly"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With