You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Moore, Amy L" <AM...@kforce.com> on 2001/04/10 20:20:32 UTC

Validation Clarification

greetings everyone...
My question is this:
What would the benefits be for using the validation() vs. client-side
validation with Javascript? Granted it would probably be faster for the user
if javascript validation was used, but in a few articles that I have read
pertaining to JSP taglibs only the validation() is mentioned. Has anyone
created JSP templates/taglibs in conjuction with Javascript validation? If
so can you give me an example?

thanx for your time,
lettybug 

Re: Validation Clarification

Posted by Ted Husted <hu...@apache.org>.
"Craig R. McClanahan" wrote:
> One of the items on the TODO list for Struts 1.1 will be to support the
> optional creation of client-side JavaScript for validation of simple
> things like required fields, valid date formats, and such.  But, even if
> you utilize this feature when it becomes available, your server side
> validation methods should *always* check everything.

A good here-and-now candidate for this is David Winderfeldt's validator, 

< http://home.earthlink.net/~dwinterfeldt/ >

which uses regular expressions to automatically validate input on both
the client and server-side.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/

Re: Validation Clarification

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 10 Apr 2001, Moore, Amy L wrote:

> greetings everyone...
> My question is this:
> What would the benefits be for using the validation() vs. client-side
> validation with Javascript? Granted it would probably be faster for the user
> if javascript validation was used, but in a few articles that I have read
> pertaining to JSP taglibs only the validation() is mentioned. Has anyone
> created JSP templates/taglibs in conjuction with Javascript validation? If
> so can you give me an example?
> 
> thanx for your time,
> lettybug 
> 

This has been answered, but I would like to emphasize a couple of points:

* As a general rule, you want to validate as close to the user as possible
  (i.e. using JavaScript on the client side if possible) to make the user
  interface of your application feel more responsive.

* It is not always possible to validate some input fields ("is the
  customer number that the user just entered valid?").  So, you will need
  to validate some things on the server side anyway.

* Therefore, most of the time you will probably be doing some combination
  of client-side and server-side validation.

* The most important rule, though, is that server-side code should never
  ever ever ever ever trust your client!  In other words, the server side
  code should be paranoid and double check everything anyway.  (Just as
  one example of why this matters, what would happen if your user turned
  off JavaScript in their browser?).

One of the items on the TODO list for Struts 1.1 will be to support the
optional creation of client-side JavaScript for validation of simple
things like required fields, valid date formats, and such.  But, even if
you utilize this feature when it becomes available, your server side
validation methods should *always* check everything.

Craig



Re: Validation Clarification

Posted by David Winterfeldt <dw...@yahoo.com>.
I've been working on something that generates
Javascript based on your server side validation.  I
think it is always important to perform your
validation server side.  It is the only thing you can
guarantee will happen.  If you want to also have some
of the validation done client side to check for
required fields and other basic things, I think that
is fine.  You should just keep in mind that the client
could have Javascript turned off or be using a browser
that doesn't properly run the Javascript you wrote so
it is important to also do the validation server side.
 I have what I've done posted at this URL.
http://home.earthlink.net/~dwinterfeldt

David

--- "Moore, Amy L" <AM...@kforce.com> wrote:
> greetings everyone...
> My question is this:
> What would the benefits be for using the
> validation() vs. client-side
> validation with Javascript? Granted it would
> probably be faster for the user
> if javascript validation was used, but in a few
> articles that I have read
> pertaining to JSP taglibs only the validation() is
> mentioned. Has anyone
> created JSP templates/taglibs in conjuction with
> Javascript validation? If
> so can you give me an example?
> 
> thanx for your time,
> lettybug 


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/