[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ajug-members]: jsp form question
Jason,
I'm assuming your not using Struts or have requirements for server side
validation, but are relying on client side validation.
For a fairly clean way to do this in JavaScript, I'd add script to the
<form> tag's onsubmit event that calls a validation function and returns
a boolean true/false something like:
<form onsubmit="return thisFormValidator(this)"....
Your function (thisFormValidator) would return a false if the form isn't
valid and thereby halt the form post. This function could contain simple
per field validations for a short/simple form or loop the collection of
form fields to be validated, picking them with the typeof value for text
inputs, checkboxes etc.
There's a ton of script source sites on the web with more sophisticated
validations for things like correct email format etc... if I dare use
the work sophisticated in the same sentence as JavaScript ;-)
On Fri, 2004-04-02 at 09:01, Jason Kretzer/STAR BASE Consulting Inc.
wrote:
> Good morning all,
>
> I have a question about form submission. I have a jsp that has a form
> of about 12 input fields. All of the fields are required to have
> something in them. Is there a way to have a javascript to do this and
> then still POST the form to a servlet?
>
> Thanks,
>
> -Jason
- References:
- jsp form question
- From: "Jason Kretzer/STAR BASE Consulting Inc." <JKretzer@starbaseinc.com>