Introduction
This article explains how to validate name, email and phone number in a web page using JavaScript validations in ASP.Net.
In this example, I am using three textboxes. The first TextBox is Name that allows only characters and spaces. The second TextBox is Email that only allows email format. A third TextBox is a phone number, it only allows numbers.
Coding
Validation.aspx
Output 1
We click on the "Submit" button without entering any values in the textboxes:
Output 2
We entered all incorrect values in the textboxes:
Output 3
We have entered an incorrect value in only the Name TextBox:
Output 4
We have entered an incorrect value in only the Email TextBox:
Output 5
We have entered an incorrect value in only the phone number TextBox:
Output 6
We have entered a correct value in all textboxes:
For more information, download the attached sample application.