Hi all, I'm having a bit of trouble with this validation script. My system has two functions really, one allows a user to raise a purchase requisition and the other is the option to raise a Request For Quote (RFQ). Both these forms enter the data into the same database table, with the only difference being a check digit equal to true in the requisition and false in the RFQ. Basically I have a form which allows users to update an RFQ with any additional information they need to provide. However it also has the ability to change the RFQ to a Purchase Requisition by the user ticking the checkbox (Submit as Req), hence the check digit mentioned earlier will equal true and the information will be seen as a Requisition and not a RFQ.
I have form validation working on the Requisition Form but none working on the RFQ form as the user probably will not have all the information and some of the fields will remain blank. I therefore want validation to be working on the Update page but only if the Checkbox value is equal to true. If checkbox = true then Data should be seen as requisition and all fields must be completed, else data seen as RFQ and blank fields are allowed... I hope this makes sense!
The code I have so far is:
function validate_form ( )
{
valid = true;
if ( document.newRfq.chkSubReq.checked == true )
{
for(var x=1; x<=12; x++)
{
if ( document.newRfq.elements['Qty'+x].value != "" && document.newRfq.elements['Desc'+x].value == "" | document.newRfq.elements['Stk'+x].value == "" | document.newRfq.elements['GLcolumn'+x].selectedIndex == 0 | document.newRfq.elements['currency'+x].selectedIndex == 0 | document.newRfq.elements['Prc'+x].value =="" | document.newRfq.elements['slcUnit'+x].selectedIndex == 0)
{
alert ( "Please check all entries are completed for line " +x );
valid = false;
}
}
}
return valid;
}
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).