form Tag

 

FORM TAG

  • Form tag allows us to accept input from a user.
  • Each form contains a form element that contains special controls, such as buttons, text fields, checkboxes, Submit buttons, and menus.
  • inside a <form> tag. The purpose of the <form> tag is to indicate where and how the user’s input should be sent

 ·        Common Form Elements

  •           <input>
  •         <button
  •         <select>
  •         <textarea>
  •         <label>

A    Attributes:

  • Action: Action specifies the URL to which the form is submitted.
  •   Method: The method attribute supports two values: get and post.
  •   Name: The name of the optional form. 
  •  Target: It specifies where to open the document that is the result of a form submission. 
  •  Autocomplete: It tells the browser to attempt to predict the value when a user is typing in a form control. It can have the value of on or off.
  •   Enctype: Enctype defines how form data is encoded when it’s sent to the server
  •  Novalidate: Novalidate that lets you turn off validation on your forms           

C   Common <input> Types

        Structure

        <input type=”” id=”” value=””>

Example: <input type="email" id="email" name="email"              placeholder="example:@example.com">

Type: which specifies what kind of form control to display.

“Text” -                      Single-line text input

“Password” -            Masked text input for passwords

“Checkbox”-            Toggle for selecting multiple options

“Radio”-                    Single selection from multiple options

“Submit”-                 Button to submit form data

“Button”-                  General-purpose button

Value: To display text in the text control before the user enters any information.

Name:  It associates a name with the data entered in that field when the data is

             sent to the server. 

Placeholder:  It make a suggestion as to what the user should write value

                         submitted other form data.

 ID: The server script will be able to process the value.

<fieldset> tag

The fieldset tag grouped form element into one form,<legend>tag display  the caption.

Example: 1

<html>

<head><title> MY  page </title></head>

<body>

 <form action="#" method="post">

<fieldset>

  <label for="fname">First name:</label>

  <input type="text" id="fname" name="fname"><br><br>

  <label for="lname">Last name:</label>

<input type="text" id="lname" name="lname"><br><br>

<label for="male">Gender:</label>

       <input type="radio" id="male"  name="gender" value="male">

    <label for="male">Male</label>

    <input type="radio" id="female"  name="gender" value="female">

    <label for="female">Female</label>

    <input type="radio" id="other"  name="gender" value="other">

        <label for="other">Other</label><br><br>

<label for="subject">subject:</label>

          <input type="checkbox" id="html" name="fav_language" value="HTML">

  <label for="html">HTML</label>

  <input type="checkbox" id="css" name="fav_language" value="CSS">

  <label for="css">CSS</label>

  <input type="checkbox" id="javascript" name="fav_languagevalue="JavaScript">

  <label for="javascript">JavaScript</label><br><br>

  &nbsp&nbsp&nbsp<input type="submit" value="Submit">

</fieldset>

    </form>

</body>

</html>

OUT-PUT





Example:2
<html>

<head><title> MY  page </title></head>

<body>
<fieldset>
<legend>form1</legend>
 <form action="#" method="post">
 <label for="email">Email</label><br>
 <input type="email" id="email" name="email"placeholder="example:@example.com"><br>
 <label for="pw">Password</label><br>
 <input type="Password" id="pw" name="pw"placeholder="Password"><br><br>
 &nbsp&nbsp&nbsp <input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>
OUT-PUT






<select> tag

The select tag create drop-down menu in your form. 
<option> tag
The option tag inserted element in created drop-down menu.

Example:

<html>
<head><title>my page</title></head>
<body>
<form action="post">
<label for="name"> Name 
<input type="name" id="name"><br>
<label for="class"> Class
<select name="class">
<option value="bcafy">BcaFy
<option value="bcafy">BcaSy
<option value="bcafy">BcaTy</select>
</form></body></html>

OUT-PUT

























Popular posts from this blog

Introduction of PHP

English

Speech of Shah Rukh Khan- Towards the dream