Use a Javascript to validate the form.

like this


In the head

<script language="JavaScript">
function checkForm()

{
 if (document.forms[0].firstname.value==''){
   alert('Please complete the form.');
 }else

  document.forms[0].submit();     
}  
</script>
In the body

<form name="form1" method="post" action="/servlet/AddUserServlet">
<input type="text" name="firstname" class="text3">
<input type="submit" name="sub" value="Post" onClick="checkForm()">



reg Daniel

----- Original Message ----- 
From: "Sanjib Biswas" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 13, 2001 8:45 AM
Subject: Form processing


> Hi,
> in my form generated by my JSP page I want to have some validation added on the 
>submit event of a button and on sucessful validation I want to forward it to a 
>servlet. How do I do it?
> 
> Sanjeev
> 
> ===========================================================================
> 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://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> 

==========================================================================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://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
  • ... Maurice Coyle - Sun ireland - Software Products and Platforms - Internationalization Engineer
    • ... Jamel Tayeb
    • ... Albert Wong
    • ... Willy LEGIMAN
    • ... Anabathula Jagadeesh
    • ... Sanjib Biswas
      • ... Daniel Bergenhus
    • ... Sachin S. Khanna
    • ... Hoorn, Michiel van
      • ... Mayuresh Kadu
    • ... Daniel Bergenhus
      • ... Dheil Corona
    • ... Paul Foxton
    • ... Hoorn, Michiel van
      • ... Carlos Telleria
    • ... Paul Foxton

Reply via email to