In my jsp, for certain conditions I want the checkbox to be present but do not want to allow the user to check it or uncheck it.
I am not sure how I can achieve this. I tried the following
<form:checkbox path="..." disabled = "disabled">
<form:checkbox path="..." disabled = "true">
<form:checkbox path="..." readonly = "readonly">
Nothing seem to work.
Can someone throw some light on this?
Thanks..
disabled
attribute in <spring:checkbox>
should be either set to true
or false
and checkbox don't have readonly
attribute. So
<form:checkbox path="corespondingPath" disabled = "true">
should work.
Few link
Spring doc link.
Readonly and Disabled property in Spring form input
You can use JSTL to add it depending on some condition
<c:choose>
<c:when test="${condition}">
// Add checkbox with disabled="true"
<form:checkbox path="desiredPAth" disabled="true" />
</c:when>
<c:otherwise>
// Do something else
</c:otherwise>
</c:choose>
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