0% found this document useful (0 votes)
15 views3 pages

DAY 5-Forms Part 3

The document outlines various HTML form attributes including `action`, `method`, `name`, `placeholder`, `value`, `maxlength`, `minlength`, `step`, and `enctype`. Each attribute is described with its purpose, usage, and examples. These attributes are essential for defining how form data is collected and processed on the server.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

DAY 5-Forms Part 3

The document outlines various HTML form attributes including `action`, `method`, `name`, `placeholder`, `value`, `maxlength`, `minlength`, `step`, and `enctype`. Each attribute is described with its purpose, usage, and examples. These attributes are essential for defining how form data is collected and processed on the server.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DAY 5 – FORMS PART 2

1. action Attribute:

- The `action` attribute specifies the URL where the form data should be sent when the user
submits the form.

- It defines the server-side script or endpoint responsible for processing the form data.

Example:

<form action="submit.php" method="post">

<!-- Form elements go here -->


</form>

2. method Attribute (GET and POST):

- The `method` attribute specifies how the form data should be sent to the server. It can have two
values: "get" or "post."

- "GET" appends form data to the URL, making it visible in the address bar.

- "POST" sends form data in the HTTP request body, keeping it hidden.

Example:

<form action="submit.php" method="get">


<!-- Form elements go here -->
</form>

3. name` Attribute in `<input>` Element:

- The `name` attribute assigns a name to an input element. It's used to identify and reference the
input data when the form is submitted.

- The name is crucial for server-side processing to access the submitted data.

Example:

<input type="text" name="username">

4. placeholder Attribute:
- The `placeholder` attribute provides a hint or example text inside an input field to guide users on
what to enter.

- It is displayed as grayed-out text and disappears when the user starts typing.

Example:

<input type="email" name="user_email" placeholder="Enter your email">

5. value` Attribute:

- The `value` attribute sets an initial value for an input element.

- It can be used to prepopulate input fields with default or saved data.

Example:

<input type="text" name="first_name" value="John">

6. maxlength` and `minlength` Attributes:

- `maxlength` specifies the maximum number of characters allowed in a text input.

- `minlength` specifies the minimum number of characters required in a text input.

Example:

<input type="text" name="password" maxlength="20" minlength="8">

7. step Attribute in `<input>` Element (for number input):

- The `step` attribute is used with `<input type="number">` to specify the increment or decrement
value when the user interacts with the input.

- It controls how much the value should change when using up/down arrows or spinner controls.

Example:

<input type="number" name="quantity" step="1">

8. enctype Attribute (Multipart Form Data):


- The `enctype` attribute specifies the encoding type for form data when file uploads are involved.

- For file uploads, you should use `enctype="multipart/form-data"` to ensure proper data
transmission.

Example:

<form action="upload.php" method="post" enctype="multipart/form-data">


<!-- File input element goes here -->
</form>

You might also like