Thanks For the code snippet. I was just calling the function "checkFields()"
in the
"onsubmit" attribute. I changed it to "return checkFields()" and its working
fine now.




> -----Original Message-----
> From: Gare, Tref [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 26, 2002 7:54 PM
> To: [EMAIL PROTECTED]
> Subject: Re: HTML Form submit action and JSP interaction...
>
>
> You might need to submit the code for me to be able to help more
> effectively,
> but it seems that you're javascript may not be doing all of it's job.
>
> If I were trying to achieve the same thing I'd do something like the
> following.  It should only ever get around to submitting if the
> checkSubmit() function returns true.
>
>
>
> <html>
> <head>
>
> <script language="javascript">
>         //function to confirm that username and password
> fields have been
> populated.
>         //It could use further validation to check length,
> type of content
> etc etc
>         function checkSubmit(){
>                 if(document.blahForm.username.value == "" ||
> document.blahForm.password.value==""){
>                         alert("must fill in the username and
> password fields
> before submitting");
>                         return false;
>                 }else{
>                         return true;
>                 }
>         }
>
>
> </script>
> </head>
> <body>
>
> <form name="blahForm" action="blah.jsp" method="POST" onsubmit="return
> checkSubmit()">
> <input type="text" name="username" value="">
> <input type="password" name="password" value="">
> <input type="submit" name="submit" value="submit form">
> </form>
>
> </body>
> </html>
>
> > -----Original Message-----
> > From: Rajkumar, Haripriya (Haripriya) [SMTP:[EMAIL PROTECTED]]
> > Sent: Thursday,27 June 2002 2:36
> > To:   [EMAIL PROTECTED]
> > Subject:      HTML Form submit action and JSP interaction...
> >
> > Hi,
> >
> > I am writing a simple login validation pgm. I have a HTML
> file which has
> > the
> >
> > login form and it action points to a JSP page that needs to
> be displayed
> > ONLY AFTER the
> > user has been successfully validated.
> >
> > Also, I have a JavaScript file that holds function to check
> for empty
> > fields
> > in the form and
> > sends an alert.
> >
> > Basically
> >
> > 1. If empty fields are present the JavaScript, alert needs
> to be called
> > and
> > the HTML form page
> > should still be visible.
> >
> > 2. If userId and password are entered but are not valid,
> then the JSP page
> > that prints out the
> > error message has to be displayed.
> >
> >
> > Here is what happens. When the HTML form is called in the
> browser, and
> > userid or password is not entered
> > then the alert is displayed properly. After entering the userid and
> > password, it goes to the JSP
> > page properly.
> >
> > BUT when, I use the browser's BACK button, and go to the
> HTML form page,
> > and
> > if the password field is not
> > present and try to hit submit button, The Alert message is
> displayed AS
> > WELL
> > AS the JSP page too, seems
> > like the SUBMIT action is getting called. How do I fix
> this, so that even
> > if
> > teh user, hits the
> > BACK button and tries to login giving empty fields, ONLY
> the alert has to
> > be
> > displayed.
> >
> > Any pointers???
> > Thanks
> > PHR
> >
> >
> ==============================================================
> ============
> > =
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set
> JSP-INTEREST
> > DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> >  http://archives.java.sun.com/jsp-interest.html
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.jsp
> >  http://www.jguru.com/faq/index.jsp
> >  http://www.jspinsider.com
>
> ==============================================================
> =============
> To unsubscribe: mailto [EMAIL PROTECTED] with body:
> "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set
> JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to