I need some help with JavaScript code, please. I have a form that asks a question, if you answer yes, then more fields appear. I want to set it to if yes, those fields become mandatory.
This part works fine:
<label for="export">Do you export?</label>
<ui:inputSelect value="{!v.account.Export__c }" aura:id="export">
<ui:inputSelectOption text="No" />
<ui:inputSelectOption text="Yes" />
</ui:inputSelect>
<aura:if isTrue="{!v.account.Export__c == 'Yes'}">
I would like to make the below mandatory only if yes is selected:
<label for="export-where">Where do you export?</label>
<ui:inputSelect multiple="true" aura:id="export-where" value=" !v.account.Export_to_where__c}" change="{!c.handleExports}">
<ui:inputSelectOption text="Option 1" />
<ui:inputSelectOption text="Option 2" />
<ui:inputSelectOption text="Option 3" />
</ui:inputSelect>
<label for="export-what">What do you export?</label>
<ui:inputTextArea aura:id="export-what" value="{!v.account.Export_what__c}" maxlength="32768" />
</aura:if>
The below JavaScript works as all being mandatory.
else if(getCurrentStep == 3){
this.removeBorder(component, 'export');
if((account.Export__c == 'No')) {
return true;
}
else{
component.set("v.errorMessage","* Please fill all the required details");
if(account.Export__c =='Yes' || account.Export_to_where__c == 'undefined' || account.Export_to_where__c == null || account.Export_to_where__c.trim() == '') {
this.addBorder(component, 'export-where');
}
}
How do I change it so that when the Export_to_where__c question is filled it validates? Any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire