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
Shivendra Singh PawarShivendra Singh Pawar 

How to Show a message on form submit in lightning

Dear Team,

Greetings !!!

We have created lightning: button in .cmp file. On .js file, we have written code for insert, after data saved all textboxes getting blank. Now we have to display the success message box. Plz, let us know how to display a message box. Code is as follows :
 
save: function(component, event) {
    var getCon = component.get("v.NewCon");

    var action = component.get("c.CreateNewContact");

    action.setParams({
      con: getCon
    });

    action.setCallback(this, function(a) {
      var state = a.getState();

      if (state === "SUCCESS") {
        var name = a.getReturnValue();

        component.set("v.NewCon.FirstName", "");
        component.set("v.NewCon.LastName", "");
        component.set("v.NewCon.Email", "");
        component.set("v.NewCon.Phone", "");
        component.set("v.NewCon.Description", "");
      }
    });

 
Alain CabonAlain Cabon
Is it a toast?
 
    var toastEvent = $A.get("e.force:showToast");
    toastEvent.setParams({
        "title": "Success!",
        "type": 'success',
        "message": "The record has been created successfully."
    });
    toastEvent.fire();

https://developer.salesforce.com/docs/component-library/bundle/force:showToast/documentation

 
Deepali KulshresthaDeepali Kulshrestha
Hi Shivendra,

Greetings to you!

Use the below links. It must provide solution of your problem

To display alert message on click of button-
https://salesforce.stackexchange.com/questions/152837/lightning-component-to-display-alert-message-on-click-of-button

To show toast in lightning record page by using force:showToast. Toast are the message box or you can say notification which developer can show according to action
of the user.
https://webkul.com/blog/forceshowtoast-in-lightning/

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

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com