users
[Top] [All Lists]

RE: [cinjug-users] jsp form question

To: "'Sam Corder'" <samus@xxxxxxxxxxxxxxxxxxxxxx>, <users@xxxxxxxxxx>
Subject: RE: [cinjug-users] jsp form question
From: "Robert Casto" <robert@xxxxxxxxxxxxx>
Date: Fri, 2 Apr 2004 11:56:43 -0500
Delivered-to: mailing list users@cinjug.org
In-reply-to: <20040402.SSO.97842300@feudalkingdoms.tzo.org>
Mailing-list: contact users-help@cinjug.org; run by ezmlm
Thread-index: AcQYzYyhit80TndFTi6l8OnDo+kXEwABb4AQ
I have noticed though that the new IE 6.0+ has problems with doing POST and
that you need those lines to ensure the submit is done correctly. Otherwise
the user things the submit happened, but the browser never sends it to the
server. It will do a GET method instead which is not what is wanted.

Robert Casto
President - CinciJava LLC
Phone: 513-755-2221
FAX: 831-307-7638
robert@xxxxxxxxxxxxx

 

 


-----Original Message-----
From: Sam Corder [mailto:samus@xxxxxxxxxxxxxxxxxxxxxx] 
Sent: Friday, April 02, 2004 11:19 AM
To: users@xxxxxxxxxx
Subject: Re: [cinjug-users] jsp form question

Actually you don't need the else part there at all.  If you return a false
from a function in an onSubmit or onClick the action gets cancelled.  So all
you need to do is change your  function to look like:

                 if(thisForm.comp.value == '')
                 {
                         alert('Company name is required.');
                         thisForm.comp.focus();
                         return false;
                 }
                  ...
                  return true;

Also make sure you do the same validation on the server side.  Never trust
the
client to send you good data.

-Sam Corder
Jason Kretzer/STAR BASE Consulting Inc. (JKretzer@xxxxxxxxxxxxxxx) wrote:
>
> OK, I have it now.  I used :
>
> //for the submit button
> onSubmit=validateFields();
>
> //then in validateFields I got the form and checked each field for a value
> and then submitted when all had a value, like so:
> var thisForm = document.forms[0];
>
>                 if(thisForm.comp.value == '')
>                 {
>                         alert('Company name is required.');
>                         thisForm.comp.focus();
>                         return;
>                 }
>                 else if(thisForm.desc.value == '')
>                 {
>                         alert('Short description is required.');
>                         thisForm.desc.focus();
>                         return;
>                 }
>                 else if(thisForm.addr.value == '')
>                 {
>                         alert('An address is required.');
>                         thisForm.addr.focus();
>                         return;
>                 }
>                 ///....etc.
>                 else
>                 {
>                         thisForm.method.value = 'POST';
>                         thisForm.action = 'FormProcessor?action=a';
>                         thisForm.submit();
>                 }
>
> Thanks for the help everyone.  My problem is that I did not know you could
> perform the commands in that last else in javascript.
>
> -Jason
>
>
>
>
> "Jason Kretzer/STAR BASE Consulting Inc." <JKretzer@xxxxxxxxxxxxxxx>
> 04/02/2004 09:00 AM
>
> To
> users@xxxxxxxxxx
> cc
>
> Subject
> [cinjug-users] jsp form question
>
>
>
>
>
>
>
> 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
>


---------
You may unsubscribe from this mailing list
by sending a blank email addressed to:
users-unsubscribe@xxxxxxxxxx

--
Find additional help by sending a blank email
addressed to:
users-help@xxxxxxxxxx




<Prev in Thread] Current Thread [Next in Thread>