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
Shruti NigamShruti Nigam 

how to stop execution in lightning component?

Hi all,
in my lightning controller i want to stop execution after displaying error.
but right now after displaying error it moves further.

Anyone know how to stop execution

In below code i am comparing two dates
var fromCmp = component.find("From_date");
var fromCmpval = fromCmp.get("v.value");
var toCmp = component.find("To_date");
var toCmpval=toCmp.get("v.value");



if (fromCmpval > toCmpval) 
                {
                  
          toCmp.set("v.errors", [{message:"To Date should be Less then To Date"}]);

//here i want to stop execution after displaying error
               }


Thanks in advance.
Best Answer chosen by Shruti Nigam
Ajay K DubediAjay K Dubedi
Hi Shruti,
You just need to add a line after error message:
return false;

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi