reset lightning input field on button click in lwc -- w3web.net

How to reset lightning input field values on button click dynamic JavaScript method function Uses of “lightning-record-edit-form” & “lightning-input-field” in Lightning Web Component — LWC | How to clear lightning-input on click in lwc

Hey guys, today in this post we are going to learn about How to reset lightning input field value on button click dynamic JavaScript method function Uses of “lightning-record-edit-form” & “lightning-input-field” in Lightning Web Component — LWC.

This example we creates a form with six fields, When you click the Reset Form Button, the resetFormAction method will call and resets their initial values.

We Uses of “lightning-record-edit-form” & “lightning-input-field” element to create a form and reset() method to reset the form fields values.

Files we used in this post example

lwcResetForm.html LWc HTML File Template HTML file to reset the lightning input field values in Salesforce Lightning Web Component (LWC)
lwcResetForm.js LWC JavaScript File It’s hold a javascript on resetFormAction function to reset the lightning input field values on click button.
lwcResetForm.js-meta.xml XML Meta File It is used to where this lightning web component file you want to display as like lightning__AppPage, lightning__RecordPage, lightning__HomePage.

Final Output

How to reset lightning input field values on button click in LWC -- w3web.net

Other related post that would you like to learn in LWC

Find the below steps:-

Create Lightning Web Component HTML

Step 1:- Create Lightning Web Component HTML ➡ lwcResetForm.html

SFDX:Lightning Web Component ➡ New ➡ lwcResetForm.html

lwcResetForm.html [Lightning Web Component HTML]

Create Lightning Web Component Javascript

Step 2:- Create Lightning Web Component Javascript ➡ lwcResetForm.js

SFDX:Lightning Web Component ➡ New ➡ lwcResetForm.js

lwcResetForm.js [LWC JavaScript File]

Create Lightning Web Component Meta XML

Step 3:- Create Lightning Web Component Meta XML ➡ lwcResetForm.js-meta.xml

SFDX:Lightning Web Component ➡ New >> lwcResetForm.js-meta.xml

lwcResetForm.js-meta.xml [LWC Meta Data XML]

Create Lightning Application

Step 4:- Create Lightning Application : lwcResetFormApp.app

From Developer Console >> File >> New >> Lightning Application

lwcResetFormApp.app [Component Application File]

reset lightning input field on button click in lwc -- w3web.net

Further post that would you like to learn in LWC

Related Topics | You May Also Like

Hi, This is Vijay behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time.

4 thoughts on “How to reset lightning input field values on button click dynamic JavaScript method function Uses of “lightning-record-edit-form” & “lightning-input-field” in Lightning Web Component — LWC | How to clear lightning-input on click in lwc”

Leave a Comment