xyz xyz - 4 months ago 45
HTML Question

How to disable html button using JSTL tags

I want disable HTML button depending on value present in Spring bean.I am using JSTL

empty
property but no luck.

Here is my code

<input type="submit" value="SendEmail" disabled="${empty reportNotificationFbo.providersList}" >


Here
reportNotificationFbo
is spring bean and
providersList
is a list.

I want to disable
Submit
button if
providersList
is empty.

-Thanks.

Answer

State of the button is controlled by the presence of disabled attribute, not by its value. Try the following:

<input type="submit" value="SendEmail"
    "${(empty reportNotificationFbo.providersList) ? 'disabled' : ''}" >