What I have found the best is to use both JavaScript and server side.
Use JavaScript because it is really annoying when you enter an entire form,
hit the submit, and then wait for the server to send a response back telling
you that you didn't fill out everything. Especially if users are on a modem
and/or the server is really busy.
Use server side because not all browsers support JavaScript and if that is
your only check you could run into a lot of problems when you get invalid
data.
As for your next question I would validate everything that you care about
at the same time. The time constraint really isn't an issue. Plus there
really isn't anything more annoying on forms than when I fill out a form and
forget something. Then it gets returned with my mistake. So I fix it and
send it back only to find out that I made another mistake on a different
field. This can go on many times especially if your validation is really
strict.
As for general validation guidelines remember that not all web users are
computer people. So be nice and help out when you can. If they don't fill
out something or do it incorrectly please tell them exactly what they need
to do. Don't just send back the dry and unhelpful "You did not fill out the
form correctly." If you need something in a special format such as a date
or a phone number make it as easy as possible with multiple fields and drop
down boxes if able. If you don't like this approach then make sure your
program can parse multiple formats such as dates with dashes, slashes,
underscores, or no separating values at all. Etc for all complex inputs.
And last but not least repost the form they need to correct with their
original responses still intact. This makes it easier to see what was
entered the first time not to mention they don't have to fill out the entire
form again.
Just my opinions,
~Matt
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's JavaServlet API
Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Tripat Singh
Sent: Monday, October 30, 2000 12:27 AM
To: [EMAIL PROTECTED]
Subject: Design and Validation opinion.
Hi pals!!!
I would like to have a opinion of all of you for validating fields in the
html page.
-- Whats is the preferable way to validate fields - server side in the
servlet/jsp page or using the java script at the client end?
-- What are the advantages and disadvantages of both the techniques?
-- Suppose i choose the server side validation, should i validate ALL the
required fields
or
as soon i find the FIRST reqired field which was left blank and ask end user
to fill up all the required field(s).
Thanks and Regards
Tripat
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html