Email validation Using Ajax & PHPYou can see how email validation is done by using regular expression in PHP. We will further extend this validation by using PHP & Ajax. As you know for validation purpose we will be using the same PHP code so it is better you try to understand the PHP code by reading the email validation tutorial. We will discuss the Ajax part here only.
Usually within a form email field is required along with some other fields like name, address etc so we have kept here two other fields name and city name along with email entry field. While filling the data we will first fill name and then email and then city name. When we finish entering the email address we will exit the email address to next field, at that time the validation code written in PHP of email will be executed. So we have used onBlur event handler of email field to trigger the validation code using Ajax. Read this code line.
As you have seen we have passed the email data as entered by user to the Ajax function and then through XMLHttpRequest we will pass this email data to our php code kept at server inside a PHP file. The validation code in PHP is same as our email validation code. The output of this validation is displayed at the form here. See the demo bellow. Here is the code of this validation written in this page, you can see the source of this page to get this same script.
The HTML code to display the form ( as in the above demo ) is here
Now the code kept within email-ajax.php file is here, this is same code as explained at email validation tutorial
The above code in email-ajax.php file can be replaced by this code if you are using email filter function .
Member Signup page uses all types of validation to check userid , password , email address and other input data submitted by user. By using JQuery we need not refresh the page and backend processing for validate the data can be done by using on Blur event of the input fields.
JQuery Membership signup page.
This article is written by plus2net.com team.
|▼ Web Forms & handling data in PHP|