![](/img/trans.png)
[英]How to use if-else option in JSTL when the condition returned by javascript
[英]How to use javascript function in jstl if condition
這是我的 javascript 函數:
function isEmpty(field){
if( document.getElementsByName(field).value === '' )
return true;
return false;
}
如何在 jstl 中使用我的 javascript 函數:
<c:choose>
<c:when test ="isEmpty(firstName)">
<span class="red">please-fill-required-fields</span>
</c:when>
<c:otherwise>
<span class="red"> </span>
</c:otherwise>
</c:choose>
Jstl 代碼在服務器端執行,javascript 函數在服務器渲染頁面后執行! 因此,您不能在 jstl 代碼中使用 javascript。 相反,您應該使用 jstl(而不是 javascript)來檢查空值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.