Home arrow JavaScript arrow Page 3 - A Basic Approach to Server-side Data Validation with AJAX
JAVASCRIPT

A Basic Approach to Server-side Data Validation with AJAX


Would you like to learn how to validate user-supplied data using JavaScript, but without the risks? This article will show you how to handle it in a way that takes advantage of JavaScript's pluses, but adds a level of safety, thanks to AJAX. It is the first of three parts.

Author Info:
By: Alejandro Gervasio
Rating: 4 stars4 stars4 stars4 stars4 stars / 14
July 11, 2006
TABLE OF CONTENTS:
  1. · A Basic Approach to Server-side Data Validation with AJAX
  2. · A picture is worth a thousand words: defining the look and feel of the application
  3. · Building a basic sample form: defining the front-end of the AJAX-based form checking system
  4. · Spicing up the sample form: defining a few CSS declarations
  5. · Putting the pieces together: listing the full (X)HTML markup and CSS styles of the AJAX application

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
A Basic Approach to Server-side Data Validation with AJAX - Building a basic sample form: defining the front-end of the AJAX-based form checking system
(Page 3 of 5 )

In this particular case, defining the front-end of this AJAX-driven application for checking online forms is a very simple process. It will be limited to coding a simple web form, which will be comprised of a few text boxes to allow a user to enter typical data, such as the user's First name, Last Name, and finally an email address.

Based on the above description, here is the respective (X)HTML markup code that constructs the sample form in question:

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/
xhtml1-transitional.dtd">
  <html>
  <head>
    <title>AJAX-BASED FORM VALIDATOR</title>
  </head>
  <body>
    <div><p>AJAX-BASED FORM VALIDATOR</p></div>
    <div id="formcontainer">
      <form method="post" action="nextpage.php">
        <p>First Name <input name="fname" type="text" required="Empty" class="inputbox" title="Enter your First Name (at least 8 characters)" /></p>
        <p>Last Name <input name="lname" type="text" required="Empty" class="inputbox" title="Enter your Last Name (at least 8 characters)" /></p>
        <p>Email <input name="email" type="text" required="EmailWin" class="inputbox" title="Enter a valid email address" /></p>
        <p><input type="submit" value="Send Data" class="formbutton" /></p>
      </form>
    <div>
  </body>
  </html>

As you can see, the (X)HTML markup code listed above renders a simple online form, which is made up of three text fields: First Name, Last Name and Email respectively. Additionally, I added a "required" attribute to each field, indicating that these boxes must be filled. However don't you worry about the values assigned to this attribute, since I'll explain its correct meaning when I cover the development of the corresponding PHP validation routines later on.

So far, I created the basic structure of the sample online form, which will be used for testing the capabilities of this AJAX-based application, handy for validating forms. Now, the next logical step consists of tying the corresponding CSS styles to each element of the aforementioned form, to make it look a little more appealing and polished.

With reference to spicing up the corresponding sample form, I recommend you  read the next section so you can see how this will be done. Don't worry, I'll be there waiting for you.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials