How to Add Validation Rule for Text Field in Salesforce

There will be times, we all need to add a validation rule for the text field in Salesforce. And here, I will explain how to add a validation rule for the text field in Salesforce. We will also discuss, how to add a validation rule for the blank text field in Salesforce.

Recently, I was working in Salesforce, where we got a requirement to add a validation rule for the text field in Salesforce. So, in this blog, I will also explain, how to add a validation rule for the name field in Salesforce.

  • How to add a validation rule for a text field in Salesforce
  • How to add validation rule for a text field in Salesforce lightning
  • How to add a validation rule for a text field in Salesforce Classic
  • How to add a validation rule for a blank text field in Salesforce
  • How to add a validation rule for a long text field in Salesforce

How to add a validation rule for a text field in Salesforce

A Validation rule is a way to control input in a text box field and after applying the validation rule a validation text is generated that helps the user whose input data is not valid.

So, if you want to learn how to add a validation rule for the name field in salesforce follow these steps:

  • Login into the salesforce account, go to the setup, and then click on the object manager that is present beside the home tab.
  • After clicking on the object manager, then search for the object in the Quick Find Box after that click on the object.
  • After clicking on the object, select the validation rule that is present on the left sidebar.
  • After clicking on the validation rule, fill the all information that we require to complete the validation rule, then click on save.
  • After clicking on save, now check if we do not fill the text field the error message is displayed on the top.
  • If we fill the complete information and the information is correct then our validation rule is applied successfully.

Now, let’s move ahead and see how to add a validation rule for the text field in Salesforce. We will explore both the salesforce experiences: Salesforce lightning and Salesforce Classic.

Read How to use OR operator in Validation Rule in Salesforce

How to add validation rule for a text field in Salesforce lightning

Salesforce Lightning is a modern view of the salesforce platform that is fast, easy, and filled with a wide variety of options.

Tech solutions Pvt Ltd is a company based in San Diego, USA. They provide all the solutions related to computers. Due to covid situation, most of their employees are working from home. So they have decided to create an account in salesforce where employees can do their work easily at home.

So, if you want to learn how to add a validation rule for a text field in salesforce follow the below-given steps:

Step-1: First, go to the setup and then click on the object manager which is present beside the home tab.

How to add validation rule for text field in salesforce
How to add validation rule for text field in salesforce

Step-2: After clicking on the object manager, then search for the account object in the Quick Find Box after that click on the account object.

How to add validation rule for text field in salesforce lightning
How to add validation rule for text field in salesforce lightning

Step-3: After clicking on the account object, select the validation rule that is present on the left sidebar.

Add validation rule for text field in salesforce
Add validation rule for text field in salesforce

Step-4: After clicking on the validation rule, click on the new option that is present on the right side.

Add validation rule for text field in salesforce lightning
Click on new option

Step-5: After clicking on the new option, fill the information related to the validation rule edit, first fill in the Rule Name which is the account number, and then fill the description: The Account number text field contains a numeric value.

Salesforce add validation rule for text field
Salesforce adds a validation rule for the text field

Step-6: After editing, the validation rule then fills the error condition formula, and first selects the functions. Here we are selecting the ISNUMBER function and then clicking on the insert field and after that clicking on check syntax.

After clicking on check syntax it shows no error found. So we can move forward and do the next step.

Salesforce lightning add validation rule for text field
Error Condition Formula

Step-7: Now fill the Error message by simply typing in the description box, then check the error location, and after that click on the save option.

Salesforce add the validation rule for text field
Save the error message

Step-9: Again click on the account object, and then select the new account and this account object is present on the nav bar.

Add the validation rule for text field in salesforce
click on new account

Step-10: Now fill the information related to the account, here you can see that we fill the account number as numeric as well as alphabetic and click on the save option the error message occurs. Review the errors on this page.

Add the validation rule for text field in salesforce lightning
Error occurs

This is how we understand how to add a validation rule for the text field in salesforce lightning.

Read Validation Rule for Name Field in Salesforce

How to add a validation rule for a text field in Salesforce Classic

Salesforce classic is the traditional user experience of salesforce and before the salesforce lightning was introduced, it was the only salesforce experience.

Follow the below steps on how to add a validation rule for the text field in salesforce classic:-

Step-1: First, go to the setup that is present in the top right corner of the salesforce classic.

On the left-hand sidebar there is the customize tab under the build app, click on the drop-down menu of customize then select the opportunities object that is present under the customize.

Under the opportunities object there is a validation rule option, click on the validation rules.

How to add validation rule for text field in salesforce classic
How to add validation rule for text field in salesforce classic

Step-2: After clicking on the validation rule, the opportunities validation rule page is open then click on the new option.

Add validation rule for text field in salesforce classic
Add validation rule for text field in salesforce classic

Step-3: After clicking on the new option, The new opportunities validation rule page opens in which we can fill the information, firstly fill the rule name and then give the description and then move forward.

Salesforce classic add validation rule for text field
Validation rule edit

Step-4: After edit, the validation rule then fills the error condition formula, first select the functions. Here we are selecting the ISNUMBER function and then clicking on the insert field and after that clicking on check syntax.

After clicking on check syntax it shows no error found. So we can move forward and do the next step.

Add validation rule for the text field in salesforce
Error condition formula

Step-5: Now fill the Error message by simply typing in the description box, then check the error location, and after that click on the save option.

Add validation rule for the text field in salesforce classic
Error message

Step-6: After clicking on the save option, the opportunities validation rule page is open and you can see the complete validation rule detail.

Salesforce classic add the validation rule for text field
Salesforce classic add the validation rule for text field

Step-8: Again click on the opportunities object, and then select the New opportunities and this opportunities object is present on the nav bar.

Salesforce classic add validation rule for the text field
click on new option

Step-9: Now fill the information related to the task, here you can see that we can fill the order number text field as alphabetic manner and click on the save option the error message occurs. Review the errors on this page.

Salesforce classic add the validation rule for the text field
Error message displayed

In this way, we understand how to add a validation rule for the text field in salesforce classic.

Read How to Use AND operator in Validation Rule in Salesforce

How to add a validation rule for a blank text field in Salesforce

Here we understand how to add a validation rule for a blank text field in salesforce. So, if you want to learn how to add a validation rule for the blank text field in salesforce follow these steps:-

Step-1: First, go to the setup and then click on the object manager which is present beside the home tab.

How to add validation rule for blank text field in salesforce
How to add validation rule for blank text field in salesforce

Step-2: After clicking on the object manager, then search for the USA Employee object in the Quick Find Box after that click on the USA Employee object.

How to add validation rule for blank text field in salesforce lightning
How to add validation rule for blank text field in salesforce lightning

Step-3: After clicking on the USA Employee object, select the validation rule that is present on the left sidebar.

Add validation rule for blank text field in salesforce
Add validation rule for blank text field in salesforce

Step-4: After clicking on the validation rule, click on the new option that is present on the right side.

Add validation rule for blank text field in salesforce classic
Click on new option

Step-5: After clicking on the new option, fill the information related to the validation rule edit, first fill in the Rule Name , and then fill the description.

Salesforce add validation rule for blank text field
Validation rule filed

Step-6: After editing, the validation rule then fills the error condition formula, and first selects the functions. Here we are selecting the ISBLANK function and then clicking on the insert field and after that clicking on check syntax.

After clicking on check syntax it shows no error found. So we can move forward and do the next step.

Salesforce classic add validation rule for blank text field
Error condition formula

Step-7: Now fill the Error message by simply typing in the description box, then check the error location, and after that click on the save option.

Salesforce add the validation rule for blank text field
Error message

Step-8: After clicking on the save option, the USA Employeee validation rule page is open and you can see the complete validation rule detail.

Salesforce classic add the validation rule for blank text field
Salesforce lightning add the validation rule for blank text field

Step-9: Again click on the task object, and then select the New USA Employee, and this USA Employee object is present on the nav bar.

Add the validation rule for blank text field
Clock on new USA employee

Step-10: Now fill the information related to the USA Employeee, here you can see that we can not fill the name field and click on the save option the error message occurs. Review the errors on this page.

Add the validation rule for blank text field in salesforce lightning
error message display

So, with this, we understand how to add a validation rule for the last name field in salesforce.

Read How to Bulk Add Leads in Salesforce

How to add a validation rule for a long text field in Salesforce

Here we understand how to add a validation rule for a long text field in salesforce. So, if you want to learn how to add a validation rule for a long text field in salesforce follow these steps:-

Step-1: First, go to the setup and then click on the object manager which is present beside the home tab.

How to add validation rule for long text field in salesforce
How to add validation rule for long text field in salesforce

Step-2: After clicking on the object manager, then search for the opportunity object in the Quick Find Box after that click on the opportunity object.

How to add validation rule for long text field in salesforce lightning
How to add validation rule for long text field in salesforce lightning

Step-3: After clicking on the opportunity object, select the validation rule that is present on the left sidebar.

Add validation rule for long text field in salesforce
Click on validation rule

Step-4: After clicking on the validation rule, click on the new option that is present on the right side.

Add validation rule for long text field in salesforce lightning
click on new option

Step-5: After clicking on the new option, fill the information related to the validation rule edit, first fill in the Rule Name , and then fill the description.

Salesforce add validation rule for long text field
Validation rule edit

Step-6: After editing, the validation rule then fills the error condition formula, and first selects the functions. Here we are clicking on the insert field and select amount and after that clicking on insert operator and select the greater than equakl to operator and after that click on check syntax.

After clicking on check syntax it shows no error found. So we can move forward and do the next step.

Salesforce lightning add validation rule for long text field
Error condition formula

Step-7: Now fill the Error message by simply typing in the description box, then check the error location, and after that click on the save option.

Add the validation rule for long text field in salesforce
error message

Step-8: After clicking on the save option, the opportunity validation rule page is open and you can see the complete validation rule detail.

Add the validation rule for long text field in salesforce lightning
Opportunity validation rule

Step-9: Again click on the task object, and then select the New opportunity, and this opportunity object is present on the nav bar.

Salesforce add the validation rule for long text field in salesforce
Click on new opportunity

Step-10: Now fill the information related to the opportunity, here you can see that we can fill the amount less than 256 and click on the save option that why the error message occurs.

If we fill the amount greater that 256 than the error can not comes up after click on save option.

Salesforce lightning add the validation rule for long text field
error message display

So, with this, we understand how to add a validation rule for the long text field in salesforce.

Read we can’t display this page because your browser blocks cross-domain cookies salesforce

Conclusion

In this tutorial, we have learned how to add validation rule for text field in salesforce, and also we have covered how to add a validation rule for the blank text field in salesforce. This can be performed on both salesforce lightning and salesforce classic.

  • How to add a validation rule for a text field in Salesforce
  • How to add validation rule for a text field in Salesforce lightning
  • How to add a validation rule for a text field in Salesforce Classic
  • How to add a validation rule for a blank text field in Salesforce
  • How to add a validation rule for a long text field in Salesforce

You may like the following salesforce tutorials: