0

I have a Lightning component where I am capturing a text field from user in below format

<lightning:input aura:id="reason" type="text" name="reason" value="{!value}" onchange="{!c.updateOtherReason}" required="true"/> 

The Submit button is enabled based on the value of this field + few other fields when they are not empty. only first time the submit button is enabled by default, after that only when field has value the button enables and if you clear the value button disables, this is handled via onchange event.

Now my concern is, my onchange function which validates the input will be called for every character entry. would it impact the performance of my component even though I don't have any controller calls in the onchange logic.

i tried adding a 3 Sec time out, but sometimes its acting weird as its reset my error if i submit immediately after clearing value. Is there any other way so that onchange can be called once the users enter couple of words

1 Answer 1

0

The onchange handler will not necessarily fire for every event (the browser decides how frequently to fire this event). As long as you're not calling the server with every event, though, it should be just fine. After all, the browser handles hundreds of events a minute (think mouse movements), so a few keystrokes are going to bog things down too much.

1
  • Thanks for the explanation..:)
    – Sooraj57
    Mar 25, 2022 at 13:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .