HTML – Forms

HTML Forms:

  • An HTML form is used to collect user input.
  • HTML form data
    • Either sent to a server for processing.
    • Or send to JavaScript code for validation before submit to server.

Send form information directly to Server:

  • Below example shows how to submit login form information to Java Servlet program.
  • The data will submit to LoginServlet program.
  • “name” attribute is used to collect the form values in Servlet program
<!DOCTYPE html>
                        <h2>Login Form</h2>
                        <form action=”LoginServlet” method=”post”>
                                    <label>Enter Username :</label>
                                    <input type=”text” name=”user”/>
                                    <label>Enter Password :</label>
                                    <input type=”password” name=”pass”>
                                    <input type=”submit” value=”Login”/>

Form elements: HTML providing form elements to take any type of input from the user. The elements are:

  1. Labels
  2. Text boxes
  3. Password fields
  4. Check boxes
  5. Radio button
  6. Drop down boxes
  7. Submit buttons…..

Form syntax: All form controls must be placed inside the <form> …. </form> tags

<form action = ”login.jsp”>
// form controls
Scroll to Top