0

I have a lightning-input tag in my LWC HTML file and i want to get the final value of the text which user inputs. I have a onchange event but it gives me value on every change. for eg. if the user inputs good. It gives me values as g,go,goo,good. I want the last value i.e. good.

<lightning-input type="text" required label="Please provide details" placeholder="Add your comments" onchange={handleTextChange} name={question.questionApiName} value={textValue}></lightning-input>

  • Just when is it that you actually need the value? During a button execution? If so, you could always find the input in your template DOM when that button is executed, and simply get that input's "value" property value. – Phil W May 22 at 9:25
1

For a lookup inputs, generally its recommended to add a timeout to avoid any unnecessary Apex calls.


If you want to get the final value after the change, use the onblur event .

The blur event fires when an element has lost focus.

Here is a playground link.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.