function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Adam PietraszekAdam Pietraszek 

Checking if lightning:textarea is blank

I'm having a hell of a time with this issue. I'm the Salesforce Admin and my dev skills are limited to front-end web dev. I inherited an org with quite a bit of code on it and I was asked to make a change to our Oppotunity.

Right now if you want to close an Opp, a Lightning Component pops up and asks you 3 questions (picklists) and 1 multi-line text box.

The Save button is disabled until you select all the dropdowns. However, management wants people to start filling in the comments so I'm trying to keep the Save button disabled until the comment box is filled out as well.

Here's the code of the lightning component for the comment box:
<lightning:textarea aura:id="closeCommentsInput" label="Close Comments" value="{!v.opp.Close_Comments__c}" required="true" minlength="1" maxlength="30000"/>
And here's the code fot he controller:
if( (component.get("v.opp.StageName") === 'Closed Won' && component.get("v.opp.Primary_Driver_for_Win__c") != '') || (component.get("v.opp.StageName") === 'Closed Lost' && component.get("v.opp.Lost_To__c") != '' && component.get("v.opp.Primary_Driver_for_Loss__c") != '') {
	component.find("saveButton").set("v.disabled","false");
	}
	else {
		component.find("saveButton").set("v.disabled","true");
		}

And here's the controller code w/ the changes I've attempted that I thought would work. Please understand that my Salesforce coding is novice at best. If I could use something like jQuery I'd have this done in a minute but i'm stumped and I'm sure I'm overlooking something major:
if( (component.get("v.opp.StageName") === 'Closed Won' && component.get("v.opp.Primary_Driver_for_Win__c") != '') && component.get("v.opp.Close_Comments__c") != '') || (component.get("v.opp.StageName") === Closed Lost' && component.get("v.opp.Lost_To__c") != '' && component.get("v.opp.Primary_Driver_for_Loss__c") != '' && component.get("v.opp.Close_Comments__c") != '') {
	component.find("saveButton").set("v.disabled","false");
	}
	else {
		component.find("saveButton").set("v.disabled","true");
		}
I've read through a lot of the Lightning Components Dev Guide but I'm lost at this point and hoping someone could point me in the right direction.

Thank you all.
 
Raj VakatiRaj Vakati
Modify  as shown below 
 
var field2Value  = component.get("v.opp.Close_Comments__c") ; 
		
		if( (component.get("v.opp.StageName") === 'Closed Won' && component.get("v.opp.Primary_Driver_for_Win__c") != '') && component.get("v.opp.Close_Comments__c") != '') || (component.get("v.opp.StageName") === Closed Lost' && component.get("v.opp.Lost_To__c") != '' && component.get("v.opp.Primary_Driver_for_Loss__c") != '' && (field2Value==null  || field2Value=='undefined')) {
	component.find("saveButton").set("v.disabled","false");
	}
	else {
		component.find("saveButton").set("v.disabled","true");
		}
		
		
Adam PietraszekAdam Pietraszek
Raj V, thanks for the answer but it's still not working.