Skip to main content

Task 4: Building a Multi-Input Form in HTML

Action Plan: "Start by breaking down your seemingly impossible goal into smaller, actionable tasks. Create a detailed plan outlining the steps required to achieve your goal. Identify any potential obstacles or challenges and brainstorm solutions to overcome them."

Affirmations: "I am committed to making the impossible possible and finishing my work. I am capable of overcoming any challenges that come my way. With persistence and determination, I will achieve success."


πŸ”Ή If you don’t understand the task, watch the video above for the answer.


Task​


Step 1: Install Git​

"Our form will include:" βœ… Username field – A text box for users to enter their name. βœ… Password field – A hidden input field for secure entry. βœ… Comment box – A multi-line text area where users can write feedback. βœ… Radio buttons – To let users select their favorite programming language. βœ… Submit button – To send the form data when completed.

Step 2: Writing the HTML Code​

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multi-Input Form</title>
</head>

<body>

<div>

<h1>Multi-Input Form</h1>

<form action="http://www.enochgeorge.com/submit.php" method="POST">

<label for="username">Username:</label>
<input type="text" id="username" name="username" placeholder="Enter your username" required>

<label for="password">Password:</label>
<input type="password" id="password" name="password" placeholder="Enter your password" required>

<label for="comments">Your Comments:</label>
<textarea id="comments" name="comments" rows="4" placeholder="Enter your comments..." required></textarea>

<p><strong>Favorite Programming Language:</strong></p>

<input type="radio" id="java" name="language" value="java" checked>
<label for="java">Java</label>

<input type="radio" id="javascript" name="language" value="javascript">
<label for="javascript">JavaScript</label>

<input type="radio" id="python" name="language" value="python">
<label for="python">Python</label>



<button type="submit">Submit</button>

</form>

</div>

</body>

</html>

"Let’s start by creating our HTML file."

1️⃣ Open your code editor (VS Code, Notepad++, etc.) 2️⃣ Create a new file called form.html 3️⃣ Type the following code:

<form> element β†’ Defines the form and its action (where data is sent).
<label> elements β†’ Provide descriptions for the input fields.
<input type="text"> β†’ A field where users can type their username.
<input type="password"> β†’ A secure field where text is hidden.
<textarea> β†’ A text box for users to write multiple lines.
Radio buttons β†’ Users can pick their favorite programming language.

Step 3: Adding Radio Buttons for Selection​

           <input type="radio" id="python" name="language" value="python" checked>
<label for="python">Python</label>

<input type="radio" id="javascript" name="language" value="javascript">
<label for="javascript">JavaScript</label>

<input type="radio" id="java" name="language" value="java">
<label for="java">Java</label>

Step 4: Adding a Submit Button​

           <button type="submit">Submit</button>

Step 4: Adding a Submit Button​

Step 5: Testing the Form

  • Save the file as form.html
  • Open it in a browser
  • Fill out the form with test data
  • Click the Submit button