001// Copyright (c) 2001 Hursh Jain (http://www.mollypages.org) 002// The Molly framework is freely distributable under the terms of an 003// MIT-style license. For details, see the molly pages web site at: 004// http://www.mollypages.org/. Use, modify, have fun ! 005 006package fc.web.forms; 007 008import javax.servlet.*; 009import javax.servlet.http.*; 010import java.io.*; 011import java.util.*; 012import java.util.regex.*; 013 014import fc.jdbc.*; 015import fc.io.*; 016import fc.util.*; 017 018/** 019Validates two text input boxes to see if they are the same. (this could 020be a text box for say email and a second text box to confirm the email). 021<p> 022Note, other rules such as required length, characters etc., are not 023checked by this validator. Add a {@link VText} to each password field for 024that purupose. 025 026@author hursh jain 027**/ 028public final class VSameText extends FormValidator 029{ 030Text field_one; 031Text field_two; 032 033/** 034@param field_one the first text box 035@param field_two the second text box 036**/ 037public VSameText(Form f, String name, String errorMessage, 038 Text field_one, Text field_two) 039 { 040 super(f, name, errorMessage); 041 Argcheck.notnull(field_one, "parm field_one was null"); 042 Argcheck.notnull(field_two, "parm field_two was null"); 043 this.field_one = field_one; 044 this.field_two = field_two; 045 } 046 047public boolean validate(FormData fd, HttpServletRequest req) 048 { 049 String one = field_one.getValue(fd); 050 String two = field_two.getValue(fd); 051 boolean result = false; 052 053 if ( one != null && one.equals(two) ) 054 result = true; 055 056 return result; 057 } 058 059} //~class VSameText 060