JavaScript
  Home arrow JavaScript arrow Page 4 - Validators: Into the Deep
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Validators: Into the Deep
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 10
    2005-09-13

    Table of Contents:
  • Validators: Into the Deep
  • Email, Mask, Date, and Length Validators
  • Constants and Variables
  • Registration Form: Putting it All Together

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Validators: Into the Deep - Registration Form: Putting it All Together


    (Page 4 of 4 )

    Until now I have simply discussed all of the Validators; now, let's see them in action. For this I will be using a registration form. To keep things simple I will concentrate only on the following fields:

    • User Name
    • Name
    • Email

    So let's get started. Up until the <form> element everything is the same as the one illustrated in the first part of this series, which is:

            < form-validation>
                 <formset>

            <form name=“registrationFormBean”>


            :
            :
                   </form>
                 </formset>
            </ form-validation>

    The first field is the user name. The rules to be applied are mandatory and the minimum length. The minimum length is three characters.

            < form-validation>
                 <formset>

            <form name=“registrationFormBean”>
         
             <
    field property="userName" depends="required,minlength">
                     <arg0 key="registration.UserName"/>
                 
    </field>
            <arg1 name="minlength"
                  key="${var:minlength}" resource="false"/>
               <var>
                      <var-name>minlength</var-name>
                      <var-value>3</var-value>
                </var>
           
           
            :
            :
                   </form>
                 </formset>
            </ form-validation>

    Next comes the Name. Here, apart from the mandatory Validator, the mask Validator will also have to be applied, so that only characters can be entered.
     
            < form-validation>
                 <formset>
                     <form name=“registrationFormBean”>
           
             <field property="name" depends="required,minlength">
                     <arg0 key="registration.UserName"/>
                 </field>
            <arg1 name="minlength"
                  key="${var:minlength}" resource="false"/>
               <var>
                      <var-name>minlength</var-name>
                      <var-value>3</var-value>
                </var>
           
           
    <field property="Name" depends="required,mask">
                <msg name="mask" key="registration.name.maskmsg"/>
                <arg0 key="registration.Name"/>
                <var>
                <var-name>mask</var-name>
                <var-value>^[a-zA-Z]*$</var-value>
                       </var>
            <field>
           
           
            :
            :
                   </form>
                 </formset>
            </ form-validation>

    Last but not least is the existing email field. Here mandatory and email validations are required.

            < form-validation>
                 <formset>
                    <form name=“registrationFormBean”>
           
             <field property="name" depends="required,minlength">
                     <arg0 key="registration.UserName"/>
                 </field>
            <arg1 name="minlength"
                  key="${var:minlength}" resource="false"/>
               <var>
                      <var-name>minlength</var-name>
                      <var-value>3</var-value>
                </var>
           
            <field property="Name" depends="required,mask">
                <msg name="mask" key="registration.name.maskmsg"/>
                <arg0 key="registration.Name"/>
                <var>
                       <var-name>mask</var-name>
                       <var-value>^[a-zA-Z]*$</var-value>
                       </var>
            <field>
           
           
    <field property="Email" depends="email">
                     <arg0 key="registration.email"/>
            </field>
           
               </form>
              </formset>
            </ form-validation>

    And that brings us to the end of this session of discussion. There are some obvious questions that are left unanswered. These include how to compare and validate the values of two fields such as password, retype password fields, and creating a custom Validator. These will be the topics of the third and last part of this tutorial/discussion series. Until next time.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · HiThis is second part of my validator framework series. The framework works with...
     

    JAVASCRIPT ARTICLES

    - Using jQuery to Preload Images with CSS and ...
    - Using Client-Side Scripting to Preload Image...
    - Removing Non-Semantic Markup when Preloading...
    - Using the Display CSS Property to Preload Im...
    - Preloading Images with CSS and JavaScript
    - Scaling and Moving Web Page Elements with th...
    - Fading, Hiding and Sliding HTML Elements wit...
    - Toggling CSS Properties with the GX JavaScri...
    - Cancel, Queue and Pause Animations with the ...
    - Producing Elastic Effects with the GX JavaSc...
    - Moving Divs Diagonally with the GX JavaScrip...
    - Moving Elements Vertically and Horizontally ...
    - Making Bouncing Effects in Parallel with the...
    - Creating Bouncing Effects with the GX JavaSc...
    - Manipulating Background Colors with the GX J...







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 10 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek