开发者

How to disable html button using JSTL tags

开发者 https://www.devze.com 2023-03-06 16:51 出处:网络
I want disable HTML button depending on value present in Spring bean.I am using JSTL empty property but no luck.

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 开发者_如何学Pythonto disable Submit button if providersList is empty.

-Thanks.


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' : ''}" >   


If you have a disabled attribute with any value it will be rendered in the browser as disabled

Try

<c:choose>
    <c:when test="${empty reportNotificationFbo.providersList}">
        <input type="submit" value="SendEmail" disabled="disabled" >
    </c:when>
    <c:otherwise>
       <input type="submit" value="SendEmail"  >
    </c:otherwise>
</c:choose> 

Sorry i haven't checked this code

0

精彩评论

暂无评论...
验证码 换一张
取 消