Home arrow JavaScript arrow Page 4 - Validators: Into the Deep
JAVASCRIPT

Validators: Into the Deep


In the first part, we saw a glimpse of what the Validator framework can do. But that is just the tip of the iceberg. The driving force behind creation of the Validator framework is reusability. This facet of the framework is but one of the many aspects that can not only reduce the web GUI development time but also enforce standards across all interfaces.

Author Info:
By: A.P.Rajshekhar
Rating: 5 stars5 stars5 stars5 stars5 stars / 14
September 13, 2005
TABLE OF CONTENTS:
  1. · Validators: Into the Deep
  2. · Email, Mask, Date, and Length Validators
  3. · Constants and Variables
  4. · Registration Form: Putting it All Together

print this article
SEARCH DEVARTICLES

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.

blog comments powered by Disqus
JAVASCRIPT ARTICLES

- Project Nashorn to Make Java, JavaScript Wor...
- JavaScript Virus Attacks Tumblr Blogs
- Google Releases Stable Dart Version, JavaScr...
- Khan Academy Unveils New JavaScript Learning...
- Accessing Nitro? There`s an App for That
- JQuery 2.0 Leaving Older IE Versions Behind
- Fastest JavaScript Engine Might Surprise You
- Microsoft Adjusting Chakra for IE 10
- Brendan Eich: We Don`t Need Google Native Cl...
- An Overview of JavaScript Statements
- An Overview of JavaScript Operators
- Overview of JavaScript Variables
- More of the Top jQuery Social Plugins
- The Top jQuery Social Plugins
- More of the Top jQuery Slider Plugins

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




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