I am trying to do a simple validation, if qty received ENTERED is different than qty ordered, a JQuery dialog box should open. For some reason this validation is working only for the first inputField. the code works if I have ONLY one record or row. but, for example if the numbers do not match in row 5 the validation doesn't occur. I will appreciate any help
Buttons:
<button type="button" onclick="validateReceived();">Save Shipment</button>
<apex:commandLink id="savingButton" action="{!SaveShipment}" value="Save Shipment" reRender="theForm" oncomplete="javascript: LoadStuff();"/>
Code page:
<apex:pageBlockTable value="{!Details}" var="d" id="thePageblock">
<apex:column headerValue="NRCode" value="{!d.NRCode}"/>
<apex:column headerValue="Ordered" >
<apex:outputText value="{!d.Ordered }" id="ordered" />
</apex:column>
<apex:column headerValue="Received">
<apex:inputText value="{!d.Received}" id="received" />
</apex:column>
</apex:pageBlockTable >
jquery validation:
<!--to validate qty received when it doesn't match qty ordered-->
<div id="dialog" title="Form Validation!" style="display:none;">
<p>The qty received entered DO NOT match the qty ordered.<br></br>
Would you like to continue?</p>
</div>
<script>
function validateReceived(){
var ordered= jQuery('[id$="ordered"]').val();
var received= jQuery('[id$="received"]').val();
if( ordered != received){
$(function() {
$("#dialog").dialog({
modal: true,
resizable: false,
buttons: {
"Yeah!": function() {
jQuery('[id$="savingButton"]').click();
$(this).dialog("close");
},
"No": function() {
$(this).dialog("close");
}
}
});
});
}else{
jQuery('[id$="savingButton"]').click();
}
}
null
from the selectors, – zokito Sep 15 '14 at 23:30(j_id0:theForm:j_id32:thePageblock:0:ordered)
and nothing has changed. – Carlos Sep 15 '14 at 23:53