JavaScript
  Home arrow JavaScript arrow Page 2 - Validators: Concluding Remarks
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: Concluding Remarks
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2005-09-28

    Table of Contents:
  • Validators: Concluding Remarks
  • Creating Custom Validators
  • Define the validation logic
  • Create an entry in the Validator-rules.xml

  • 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: Concluding Remarks - Creating Custom Validators


    (Page 2 of 4 )

    Though the Validator framework provides most of the rules, there will be times when a custom rule (which even validwhen wouldn’t satisfy) must be applied. In such circumstances, there are two possible approaches. The first one involves writing JavaScript to apply the rule. But in this case the same trouble raises its head -- the problem of reuse.

    The other approach follows the path of the Validator framework. This ensures reuse of the rule without embedding the JavaScript explicitly by the web designer. As an example I will be using the registration page itself. There is a field for phone number entry. The required rule is that the entered number has to follow a certain pattern. Though this is possible through the mask Validator, I decided to go ahead with creating a custom rule, as it would also help in experimenting with the Validator framework. So let's see how it is done, without much ado.

    To create a custom Validator, certain steps must be followed.

    First, you need to create a Java class that will contain the validation logic.  This is the basis of it all. The class would contain only one method. The method must be static, so that the framework can call it without having to create an object.

    The class I have created is as follows:

    public class PhoneRules
     {
       :
       :
    }

    More JavaScript Articles
    More By A.P.Rajshekhar


       · HiThis is the last part of my three part article on Struts validators. Please...
       · You ARE indeed able to have 3 or more test cases represented in an validwhen...
     

    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 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek