custom validation in a lightning component -- w3web.net

Custom Validation in a Lightning Input Field on Click Button in Lightning Component Salesforce | required field validation to display error messages in Salesforce lightning component

2,364 views

Hey guys, today in this post we are going to learn about How to create a form and validate all fields on a single click of button in lightning component.

Why are validation rules used?

We use form validation whenever we need to input information that is expected to some requirement from user.

There are two type of validation rule standards:- Server Side Validation and Client Side Validation.

Server Side Validation:- It is performed by server side. When we click on a button the button functionality call a method that is connected through server and it’s get all information from server.

Client Side Validation:- Client side validation performed by JavaScript function. Where does not need to connect to server. It is working very fast because it helps to reduce the server side lode.

In this example I am creating a client side validation. So go through the below points step by step.

Live Demo

Form Validation - w3web.net

 

Other related post that would you like to learn in Salesforce

 

Step:-1

formValidationCmp.cmp [Lightning Component]

 

Step:-2

formValidationCmpController.js [JavaScript File]

 

Step:-3

formValidationCmp.css [Style CSS File]

 

 
 

Further post that would you like to learn in Salesforce

 
 

 

To Find Some Important Additional Information
If you think you and your family members also like to earn money in additional time, then go this link. In this site, you can earn money for the lifetime at low effort. To Earn Unlimited Everyday With This Trick, Sign Up Free and Get Magic.. Get Started for Free

 

 

FAQ (Frequently Asked Questions)

How do you display validation error in lightning component?

To programmatically set and display an error message on a field, use the setCustomValidity() and reportValidity() methods available on the base components. For more information, see the lightning:input documentation.

How do you make fields required in aura?

To make an input field required on the client only, set required attribute to true in lightning:inputField . Use this attribute if you want to require a value in a field before the form can be submitted, and the field isn't marked required in Setup.

How do you display toast message in LWC?

A toast can also simply provide information. To display a toast notification in Lightning Experience or Experience Builder sites, import ShowToastEvent from the lightning/platformShowToastEvent module. The lwc-recipes repo has a component that lets you customize and send a toast so that you can try out the variations.

Related Topics | You May Also Like

  • Your reaction of the article ▾
 

Hi, 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. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

5 thoughts on “Custom Validation in a Lightning Input Field on Click Button in Lightning Component Salesforce | required field validation to display error messages in Salesforce lightning component”

  1. Hi. your post is so nice and I really loved reading your post.
    It was very well authored and easy to understand. Great Thanks for sharing awesome info. I really love to read your blog.

    Reply

Leave a Comment