Examples:
Made using <input type="submit"> or <button type="submit">.
Sends all the filled-in form data to the server for processing.
Example:
<input type="submit" value="Send Data" />
When you press this button, your data goes to the website owner.
Made using <input type="reset"> or <button type="reset">.
Clears all form fields to their original, empty state.
Example:
<input type="reset" value="Clear All Fields" />
If you fill a form wrongly, you use this button to start over.
Created using <input type="button"> or <button>.
Used to perform custom actions by writing JavaScript code.
Example 1:
<input type="button" value="Greet" onclick="alert('Hi there!')" />
Shows a popup saying "Hi there!"
Example 2:
<button onclick="alert('Welcome!')">Say Welcome</button>
Also displays a friendly message when clicked.
type: What it does — submit, reset, or custom.
value: Text you see on the button.
name: Used to identify the button if the form is submitted.
disabled: If set, you cannot click the button.
onclick: Runs JavaScript when you click.
Example 1:
<input type="submit" name="regButton" value="Register" disabled>
Shows a button labeled "Register", but it's greyed out, so it can't be clicked.
Example 2:
<input type="button" value="Show Date" onclick="alert(Date())">
Shows today’s date in a popup when clicked.
type: submit, reset, or button.
name: Identifies button in form.
value: Value sent to server.
disabled: Makes it unclickable.
onclick: JavaScript code runs when clicked.
Example:
<button type="reset" name="clearBtn" value="gone">Start Over</button>`
Examples:
Fun Activity:
Creating a Simple Form with All Button Types
Instructions:
<form>
<input type="text" name="student" placeholder="Your Name" /><br />
<input type="submit" value="Send" />
<input type="reset" value="Clear" />
<input type="button" value="Say Hi" onclick="alert('Hi, student!')" />
</form>
myform.html.Observations:
Examples:
<textarea name="msg" rows="4" cols="30"></textarea\>
Examples:
<textarea
placeholder="Type your feedback here..."
rows="4"
cols="40"
></textarea>
<textarea maxlength="100" rows="3" cols="40"></textarea>
<textarea readonly rows="2" cols="25">Not editable</textarea>
Examples:
Fun Activity:
Trying Out a Feedback Form
Instructions:
<form>
<label>Your Comments:</label><br />
<textarea
name="comments"
rows="5"
cols="40"
placeholder="Share your thoughts..."
></textarea>
<br /><br />
<input type="submit" value="Send Feedback" />
</form>
feedback.html.Observations:
maxlength).| Feature | Button | Multi-line Text Field |
|---|---|---|
| Tag Used | <input> or <button> | <textarea> |
| Purpose | Performs an action (submit, reset, or custom). | Accepts long text input. |
| Common Attributes | type, value, onclick, disabled | rows, cols, name, placeholder, maxlength |
| User Interaction | Click | Type and edit text |
| Example Tags | <input type="submit">, <button> | <textarea rows="5" cols="40"></textarea> |
rows and cols control the size of the <textarea>.placeholder attribute gives users a hint about what to type.readonly and disabled attributes prevent user editing.Scenario: You are making a school admission form online.
Scenario: Your friend types a long message in a feedback box and realizes she has made mistakes in all fields.
Scenario: You need to show the user a welcome message when they click a button, but don't want the form submitted or cleared.
onclick JavaScript function to show the message.Scenario: On a product review page, users want to write detailed experiences about a gadget they bought.
Scenario: Your teacher wants to make sure no one can edit the instructions displayed in a box inside the form.