Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#795295
Hi,
I have a form (task2), where at the end of the Dynaform, the User can approve or reject the case and then press SUBMIT. If it's approved, it goes on to the next task (task3). If it's rejected, it will get routed back to the very first task (task1).

However, there is a bunch of controls that have validation on them (mostly required text fields) that the user needs to fill out before going to task3. However, if the user is rejecting the form, they shouldn't have to be required to fill out those fields.

I can disable each control's validation individually under an IF statement, but I was wondering if there a way using to disable ALL the controls through a for loop or something when REJECT is selected upon submission.
#795305
If the accept/reject field is a dropdown, you can use this JavaScript:
Code: Select all
//set to the IDs of the required fields in the DynaForm:
var aRequiredIDs = [ 'clientName', 'clientAddress', 'clientTelephone'];

//function to enable or disable required fields
function setRequiredFields(newVal, oldVal) {
   if (newVal == 'accept') {
   for (aRequiredIDs in idx) {
      $( "#"+aRequiredIDs[idx] ).enableValidation();
   }
   else { //if "reject"
      $( "#"+aRequiredIDs[idx] ).disableValidation();
   }   
}

$("#decision").setOnchange(setRequiredFields); //set required fields when "decision" field changes value
setRequiredFields( $("#decision").getValue(), ''); //set required fields when DynaForm loads
Where the ID of a dropdown box with the ID "decision" can have the values of "accept" or "reject" in its list of options.

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]

Betvisa clone scripts are pre-built software solut[…]

A Bet365 Clone Script is essentially a ready-made […]