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.

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.

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

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

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.

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.

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.

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

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.

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.

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

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.

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.

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.

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

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

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.

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.

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.

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

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

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.

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.

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.

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.

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.

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.

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.

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.

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

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

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.

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.

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.

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

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

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.

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:
- How to Create a Quote in Salesforce CPQ
- How to Create Quotes in Salesforce
- Create an Opportunity in Salesforce
- How to Merge Contacts in Salesforce?
- How to Merge Accounts in Salesforce
- How to Create Cross-Object Formula fields in Salesforce
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.