Fórum
AUI:validator in loop
zhang Mr, modificado 7 Anos atrás.
AUI:validator in loop
New Member Postagens: 3 Data de Entrada: 21/03/17 Postagens Recentes
It is validating only first element in the loop
<c:foreach items="${kcInfo }" var="kc">
<c:if test="${s[0]==kc[0] }">
<aui:input type="text" name="kpiCount" id="kpiCount" value="${kc[1]}">
<%-- <aui:validator name="required" /> --%>
<aui:validator name="custom" errormessage="kpicount-error">
function (val, fieldNode, ruleValue) {
var value = document.getElementById('<portlet:namespace />kpiCount').value;
var regex = /^[0-9]*[0-9][0-9]*$/;
if(regex.test(value)){
return true;
}
return false;
}
</aui:validator>
</aui:input>
<!-- <span style="color:red;" id="notice"></span> -->
</c:if>
</c:foreach>
Mohammad Azharuddin, modificado 7 Anos atrás.
RE: AUI:validator in loop
Expert Postagens: 492 Data de Entrada: 17/09/12 Postagens Recentes
Try this <td>
<c:forEach items="${kcInfo }" var="kc" >
<c:if test="${s[0]==kc[0] }">
<aui:input type="text" name="kpiCount${kc[1]}" id="kpiCount" value="${kc[1]}">
<%-- name="kpiCount${kc[1]}" or name="kpiCount${kc[0]}" for each element we need to pass the different value for name attribute --%>
<%-- <aui:validator name="required" /> --%>
<aui:validator name="custom" errorMessage="kpicount-error">
function (val, fieldNode, ruleValue) {
var value = document.getElementById('<portlet:namespace />kpiCount').value;
var regex = /^[0-9]*[0-9][0-9]*$/;
if(regex.test(value)){
return true;
}
return false;
}
</aui:validator>
</aui:input>
<!-- <span style="color:red;" id="notice"></span> -->
</c:if>
</c:forEach>
</td>
<c:forEach items="${kcInfo }" var="kc" >
<c:if test="${s[0]==kc[0] }">
<aui:input type="text" name="kpiCount${kc[1]}" id="kpiCount" value="${kc[1]}">
<%-- name="kpiCount${kc[1]}" or name="kpiCount${kc[0]}" for each element we need to pass the different value for name attribute --%>
<%-- <aui:validator name="required" /> --%>
<aui:validator name="custom" errorMessage="kpicount-error">
function (val, fieldNode, ruleValue) {
var value = document.getElementById('<portlet:namespace />kpiCount').value;
var regex = /^[0-9]*[0-9][0-9]*$/;
if(regex.test(value)){
return true;
}
return false;
}
</aui:validator>
</aui:input>
<!-- <span style="color:red;" id="notice"></span> -->
</c:if>
</c:forEach>
</td>
zhang Mr, modificado 7 Anos atrás.
RE: AUI:validator in loop
New Member Postagens: 3 Data de Entrada: 21/03/17 Postagens RecentesMohammad Azharuddin:
Try this <td>
<c:forEach items="${kcInfo }" var="kc" >
<c:if test="${s[0]==kc[0] }">
<aui:input type="text" name="kpiCount${kc[1]}" id="kpiCount" value="${kc[1]}">
<%-- name="kpiCount${kc[1]}" or name="kpiCount${kc[0]}" for each element we need to pass the different value for name attribute --%>
<%-- <aui:validator name="required" /> --%>
<aui:validator name="custom" errorMessage="kpicount-error">
function (val, fieldNode, ruleValue) {
var value = document.getElementById('<portlet:namespace />kpiCount').value;
var regex = /^[0-9]*[0-9][0-9]*$/;
if(regex.test(value)){
return true;
}
return false;
}
</aui:validator>
</aui:input>
<!-- <span style="color:red;" id="notice"></span> -->
</c:if>
</c:forEach>
</td>
still doesn't work
can't validate the first one yet!
Thanks anyway!
Mohammad Azharuddin, modificado 7 Anos atrás.
RE: AUI:validator in loop
Expert Postagens: 492 Data de Entrada: 17/09/12 Postagens Recentes
bottom line is that , when u add a <aui:input in loop make sure that the name attribute has unique value . That value u need to pass dynamically