Sanjay,
A good site will do both. JavaScript has a number of advantages:
- client-side warning messages are immediate; this is especially important
for people who have slower connections and will end up pressing submit
eight times (and hence request the page eight times) before getting the
data right.
- it reduces unnecessary load on the server (why go to the server multiple
times just to make sure that a phone number is numeric?)
- overhead on the client side is minimal on most machines; I have only
encountered JavaScript overhead issues on Windows 3.1 machines, and as I
understand Windows 3.1 is not Y2K compliant so this is a non-issue. Also,
you can put the JavaScript code into a separate .js file to reduce page
loading time.
- JavaScript is faster and easier to write than server-side code. After
all, JavaScript was built to this kind of thing.
A quick note:
It is possible to view the source of an HTML but not change it on the
server (unless, <gasp>, your server allows this). Hence no one can change
your JavaScript code without a lot of effort (download the HTML page,
rewrite it, then access it locally in your browser and submit to the
server). They can, as previously mentioned, turn off JavaScript. Also,
older browsers may not support certain versions (or any version) of
JavaScript. These are all issues that need to be dealt, but I've found that
using both client and server-side validation is much preferable to using
just server-side validation.
Eric M. Andersen
I/T Specialist
IBM Global Services
Tel: (781) 895-2637, Fax : (781) 895-2843, t/line : 362-2637
Internet ID: [EMAIL PROTECTED]
Lotus Notes ID: Eric M Andersen/Waltham/IBM
"Radhakrishnan, Sanjay (c)"
<[EMAIL PROTECTED]>@JAVA.SUN.COM> on 12/21/99 11:22:16 AM
Please respond to "Radhakrishnan, Sanjay (c)"
<[EMAIL PROTECTED]>
Sent by: A mailing list about Java Server Pages specification and
reference <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc:
Subject: Re: offtopic:JavaScript & Security
Ross,
If i am going to do validation on the frontend and do the same on
the backend/middle tier as well, then im wondering whether i should use
JavaScript at all to do client side validation. In any case if Im going to
do serverside validation then I might as well do the validation only on the
serverside to avoid any overhead on the clientside.
So does all these websites which do ClientSide Validation also do
the same on the ServerSide.
Thanks for your time
Sanjay
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html