Hello @Margo !
I think I understood. thanks!
I commented 'alert' and put field required.
So, here my code which is working :
////////////////////////////////////if type of purchase then (first cascading questions)
fd.spRendered(() => {
fd.field('TypeOfPurchase').$on('change', () => {
// put the code here instead of spRendered()
//NEW
//accordion3, children0 (=Panel 1)
if (fd.field('TypeOfPurchase').value === 'New Purchase') {
fd.container('Accordion3').$children[0].open = true;
fd.container('Accordion3').$children[0].disabled = false;
$(fd.container('Accordion3').$children[0].$el).show();
//accordion3, children1 (=Panel 2)
fd.container('Accordion3').$children[1].open = false;
fd.container('Accordion3').$children[1].disabled = true;
//$(fd.container('Accordion3').$children[1].$el).show();
//accordion3, children2 (=Panel 3)
fd.container('Accordion3').$children[2].open = false;
fd.container('Accordion3').$children[2].disabled = true;
//$(fd.container('Accordion3').$children[2].$el).show();
}
//////////////
//RENEWAL
//accordion3, children0 (=Panel 1)
if (fd.field('TypeOfPurchase').value === 'Renewal') {
fd.container('Accordion3').$children[0].open = false;
fd.container('Accordion3').$children[0].disabled = true;
//$(fd.container('Accordion3').$children[0].$el).show();
//accordion3, children1 (=Panel 2)
fd.container('Accordion3').$children[1].open = true;
fd.container('Accordion3').$children[1].disabled = false;
$(fd.container('Accordion3').$children[1].$el).show();
//accordion3, children2 (=Panel 3)
fd.container('Accordion3').$children[2].open = false;
fd.container('Accordion3').$children[2].disabled = true;
//$(fd.container('Accordion3').$children[2].$el).show();
}
///////////////
//ADDITION
//accordion3, children0 (=Panel 1)
if (fd.field('TypeOfPurchase').value === 'Additionnal purchase under existing contract') {
fd.container('Accordion3').$children[0].open = false;
fd.container('Accordion3').$children[0].disabled = true;
//$(fd.container('Accordion3').$children[0].$el).show();
//accordion3, children1 (=Panel 2)
fd.container('Accordion3').$children[1].open = false;
fd.container('Accordion3').$children[1].disabled = true;
//$(fd.container('Accordion3').$children[1].$el).show();
//accordion3, children2 (=Panel 3)
fd.container('Accordion3').$children[2].open = true;
fd.container('Accordion3').$children[2].disabled = false;
$(fd.container('Accordion3').$children[2].$el).show();
}
///////////////////////////////
//check if the first panel (NEW) is opened and if field has value
if(fd.container('Accordion3').$children[0].open && !fd.field('PurchaseOver50KEUR').value) {
//if field is empty show alert
//alert('ALL data about [LEGAL INVOLVEMENT, new] panel are required. Pls fill it out to continue.');
fd.field('PurchaseOver50KEUR').required = true;
fd.field('QuestelCommitmentOver5Years').required = true;
fd.field('IPImpact').required = true;
fd.field('PurchaseIncludeAnExclusivity').required = true;
}
//check if the second panel (RENEWAL) is opened and if field has value
if(fd.container('Accordion3').$children[1].open && !fd.field('sof').value) {
//if field is empty show alert
//alert('ALL data about [LEGAL INVOLVEMENT, renewal] panel are required. Pls fill it out to continue.');
fd.field('sof').required = true;
fd.field('DoesThisPurchaseAmountToMoreThan50000PerYearRe').required = true;
fd.field('DoesThisPurchaseCommitQuestelForMoreThan5YearsRe').required = true;
fd.field('DoesThisPurchaseHaveOrCouldHaveAnIPImpactOnQuestelsIPRightsOrDoesItCoverADevelopmentOrCreationForWhichQuestelShallReserveIPRightsRe').required = true;
fd.field('DoesThisPurchaseIncludeAnExclusivityRe').required = true;
}
//check if the third panel (ADDITION) is opened and if field has value
if(fd.container('Accordion3').$children[2].open && !fd.field('_x0073_of2').value) {
//if field is empty show alert
//alert('ALL data about [LEGAL INVOLVEMENT, addition] panel are required. Pls fill it out to continue.');
fd.field('_x0073_of2').required = true;
fd.field('DoesThisPurchaseAmountToMoreThan50000PerYearAd').required = true;
fd.field('DoesThisPurchaseCommitQuestelForMoreThan5YearsAd').required = true;
fd.field('DoesThisPurchaseHaveOrCouldHaveAnIPImpactOnQuestelsIPRightsOrDoesItCoverADevelopmentOrCreationForWhichQuestelShallReserveIPRightsAd').required = true;
fd.field('DoesThisPurchaseIncludeAnExclusivityAd').required = true;
}
/////////////////////////////////////////////////
});
});
////////////////////////////////////if type of purchase then (first cascading questions)
I'm asking how could I put the alert on the 'submit' button ? so, I would click on "submit" then if the accordion opened contains empty field then alert the user to fill the required field.
I already have this code into the submit button :
So, I guess thing like this, in the main idea, it will be:
- if(fd.container('Accordion3').$children[0].open && !fd.field('PurchaseOver50KEUR').value) {
- or
- if(fd.container('Accordion3').$children[1].open && !fd.field('sof').value) {
- or
- if(fd.container('Accordion3').$children[2].open && !fd.field('_x0073_of2').value) {
THEN
alert('ALL data about [**** INVOLVEMENT] panel are required. Pls fill it out to continue.');
exit submission (so not save anything and return the form)
- if container .... blbaba.. is not empty
THEN
fd.field('pr....)
return fd.save();
What do you think ? is it fasable ?
thanks a lot, in advance to help me here.