This topic is locked

require entry in fields based on selection in another

10/12/2010 3:05:29 PM
ASPRunnerPro General questions
M
mfred author

Is there a way to require entry into specific fields according to what is entered into another. In my current project, I am requiring users to indicate if an edit is for closing a job or not. This is a simple yes or no question. If the user indicates yes, then I want the user to be required to make entries into 5 other fields. These are Complete_Date, Complete_Time, Status, InvoiceNumber, QCedBy, ClosedBy.
Thanks for any help.

A
ann 10/13/2010

Hi,
use JavaScript API to set fields as required depending on the condition (JavaScript Onload event):

var ctrl = Runner.getControl(pageid, 'ClosingJopField');

var ctrlStatus = Runner.getControl(pageid, 'Status');

var ctrlInvoice = Runner.getControl(pageid, 'InvoiceNumber');



function func() {

if (ctrl.getValue()=='yes'){

ctrlStatus.addValidation("IsRequired");

ctrlInvoice.addValidation("IsRequired");

}

};



ctrl.on('change', func);
M
mfred author 10/26/2010

Thank you. If I need a second set of required based on if the user selects 'Forwarding Job', would I repead as I've done below?
var ctrl = Runner.getControl(pageid, 'ClosingJobField');

var ctrlComplete_Date = Runner.getControl(pageid, 'Complete_Date');

var ctrlComplete_Time = Runner.getControl(pageid, 'Complete_Time');

var ctrlStatus = Runner.getControl(pageid, 'Status');

var ctrlInvoiceNumber = Runner.getControl(pageid, 'InvoiceNumber');

var ctrlQCedBy = Runner.getControl(pageid, 'QCedBy');

var ctrlClosedBy = Runner.getControl(pageid, 'ClosedBy');
function func() {

if (ctrl.getValue()=='Closing Job'){

ctrlComplete_Date.addValidation("IsRequired");

ctrlComplete_Time.addValidation("IsRequired");

ctrlStatus.addValidation("IsRequired");

ctrlInvoiceNumber.addValidation("IsRequired");

ctrlQCedBy.addValidation("IsRequired");

ctrlClosedBy.addValidation("IsRequired");

}

};
ctrl.on('change', func);
var ctrl = Runner.getControl(pageid, 'ClosingJobField');

var ctrlFowardedBy = Runner.getControl(pageid, 'FowardedBy');

var ctrlForwardNotes = Runner.getControl(pageid, 'ForwardNotes');
function func() {

if (ctrl.getValue()=='Forwarding Job'){

ctrlFowardedBy.addValidation("IsRequired");

ctrlForwardNotes.addValidation("IsRequired");

}

};
ctrl.on('change', func);