Validation in Register Form: Friends, when we create a registration form or login form, there is an option for our email ID and mobile number. It is often seen that when the user fills in the registration form, the email ID and mobile number are mistaken. One way to avoid this mistake is to validate your email ID and mobile number.
If we can tell the user at the time of registration that your email ID is wrong or the mobile number is incorrect, Then it is possible to get rid of all these mistakes very easily.
Also Read: How to Create Welcome Page in php – mysql Database
Each web site developer creates this email ID mobile number validation system using the coding of their choice. Here we have created registration form and login form with PHP code so we will do the mobile number and email id validation system here with PHP code.
Friends, it is often seen that different forms of data are required in different places in our registration form. This means that the data must be submitted to the registration form in the same format, otherwise the form will not work properly. All these tasks can be done very easily with this validation.
In today’s article we will learn how to validate email ID and mobile number. In this article we will learn how to do this validation with PHP and JavaScript.
Also Read: SEO Basics Rank on Google first Page
Read the full article. I hope that after reading the full article you will be able to resolve this issue related to validation. If you are a computer science student then this article will be very useful for your college seminar project.
What is the Validation?
Validation means when you are providing any data in registration form or any other form. Validation is the process of knowing whether the data is correct or not before the registration is completed.

For example, when you are enter email id option of the email-id registration form, the validation code is used before the registration is completed to see if the email id form is correct.
This validation code can be used in any data format, for example, email id, mobile number, date of birth, Aadhaar number, etc.
What is email verifier?
The code that is used to verify the email ID used in the registration form is called email verifier.
Friends, one thing to keep in mind is that we cannot use any kind of coding to check if the email id is correct. But we can easily check if the format of the email id is correct through coding.
How to Validation email id?
Every web site developer does their validation coding differently in Validation in Register Form. Here we will learn how to do email id verification using php and javascript.
Email validation php – Using php code
<?php
$email = $_POST['email'];
function email_validation($str) {
return (!preg_match(
"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^", $str))
? FALSE : TRUE;
}
// Function call
if match
if(!email_validation($email)) {
echo "Invalid email address.";
}
else {
echo "Valid email address.";
}
?>
Email validation in javascript – Using Javascript code
<input id="email" type="text"/>
<button id="testEmail" onClick="CheckEmail(document.getElementById('email').value)">Check Email</button>
<div id="output">
</div>
<script type="text/javascript">
function ValidateEmailAddress(emailString) {
// check for @ sign
var atSymbol = emailString.indexOf("@");
if(atSymbol < 1) return false;
var dot = emailString.indexOf(".");
if(dot <= atSymbol + 2) return false;
// check that the dot is not at the end
if (dot === emailString.length - 1) return false;
return true;
}
function CheckEmail(emailString)
{
//get result as true/false
var Result= ValidateEmailAddress(emailString);
if(Result)
{
document.getElementById("output").innerHTML="Your Email Id Valid ";
}
else
{
document.getElementById("output").innerHTML="Your Email Id NOT Valid ";
}
}
</script>
How to Validation Mobile Number?
Every web site developer does their validation coding differently in Validation in Register Form. Here we will learn how to do Mobile Number verification using php and javascript.
Mobile Number validation php – Using php code
<?php
$mobileno = $_POST['mobileno'];
function valid_phone($mobileno )
{
return preg_match('/^[0-9]{1}[0-9]{9}+$/', $mobileno);
}
if(!valid_phone($mobileno )){
echo "Incorrect Mobile Number !";
}else{
echo "Correct Mobile Number !";
}
?>
Mobile Number validation in javascript – Using Javascript code
<input id="txtPhoneNo" type="text" onkeypress="return isNumber(event)" />
<input type="button" value="Submit" onclick="ValidateNo();">
<script type="text/javascript">
function isNumber(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
alert("Please enter only Numbers.");
return false;
}
return true;
}
function ValidateNo() {
var phoneNo = document.getElementById('txtPhoneNo');
if (phoneNo.value == "" || phoneNo.value == null) {
alert("Please enter your Mobile No.");
return false;
}
if (phoneNo.value.length < 10 || phoneNo.value.length > 10) {
alert("Please Enter 10 Digit Mobile No.");
return false;
}
alert("Success ");
return true;
}
</script>
What is form validation?
Form validation is a technical process where all types of data are examined. Whether it is input in the correct format. This form validation can be varied on different web sites.
And the coding of this form validation depends entirely on the web developer what kind of coding he will use there.

Validation of this form works when you are providing any data in the form, then it gives error notification if the date does not follow the required format rules. It’s very simple if you need this type of validation code then you can read full article
How does a web developer validate a web page?
A web site developer validates the pages of a website in different ways. It depends entirely on the web developer how he validates the pages of the website.
What is validation error?
Friends, validation error means that when you are inputting data in a form, if you do not enter any data in a mandatory box, then this validation code displays an error notification which is called validation error notification.
For example – A form`s Name, Date of birth, Email id, Mobile number etc. Required input field. So if you do not give any data this Required input field and try to submit the form then validation code will give error notification.
Can JavaScript be used for validation?
Yes you can, If you wish, you can validate your email ID or any kind of data validation via JavaScript. You can also validation email id using PHP. I recommend to you using PHP for email id validation because it is simple for everyone.
In this article we have discussed all the details related to validation. You can view the codes as needed.
How do you perform form validation without JavaScript?
Yes you can, How do you perform form validation without JavaScript. You can validation email id using PHP code PHP code is very simple for any data validation.
PHP code is very lite coding its not decrease your website speed . Where JavaScript is decrease your website speeded.
In this article we have discussed all the details related to validation. You can view the codes as needed.
How do I validate a username?
You can easily validate the username using PHP code. It is very simple. PHP code is very lite coding its not decrease website speed . Where JavaScript is decrease website speeded.
<?php
$username = $_POST['username'];
function valid_phone($username)
{
return preg_match('/^[a-z]{5}[0-9]{3}+$/', $username); // you can change it to suit your needs
}
if(!valid_phone($username)){
echo "Incorrect Username format!";
}else{
echo "Correct Username format";
}
?>
How do I validate a username in HTML?
Sorry friends, validation is not possible using HTML code only, it will require JavaScript or php.
You can check full article for any type of validation as per your requirement you can select coding for your username validation for email id validation.
Why do we need form validation?
Form validation is a very important topic for all forms of a website. This form validation is very important because the Someone can not abuse the form unnecessarily. For this reason form needs to be validated.
The last few words
In today’s short article I have been able to tell you how to validate the email id and mobile number of the form. I hope all your ideas about this validation are clear.
You must like this article. If you have any problem with this validation, please let us know in the comment box. We will try to resolve your comment as soon as possible.