O'Reilly logo

PHP Ajax Cookbook by R. Rajesh Jeba Anbiah, Roshan Bhattarai, Milan Sedliak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a PHP Ajax contact form with validation

Validation of the input box before submitting the form has become one of the very important Ajax functionalities. The user does not have to wait until the whole form gets back with some invalid input box messages and then try to refill it again. In this task, we will build a contact form with Ajax validation.

How to do it...

  1. Let's start with HTML:
    <body> <form id="contactForm" action="#" method="post"> <h1>PHP Ajax Contact Form</h1> <div class="fieldRow"> <label for="name">Your Name:</label> <input type="text" name="name" id="name" class="required" /> </div> <div class="fieldRow"> <label for="email">Your e-mail:</label> <input type="text" name="email" id="email" class="required email" /> </div> <div ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required