Skip to content
Programming Questions · Q10

Q.Write the HTML for a simple registration form that collects a name (required) and an email address (validated as an email), with a submit button.

Maharashtra MsbshseTextbookSubjectiveImportance★★★★★est
83% · 10/12 Questions
✓ Free question

A form is built with the <form> container and controls inside it. We use a text input for the name and an email input for the address, giving both the required attribute so neither can be left empty, and relying on type="email" so the browser checks the address format automatically. Each control is joined to a <label> for accessibility.

<form action="register.php" method="post">
  <label for="name">Name:</label>
  <input type="text" id="name" name="name" required>

  <label for="email">Email:</label>
  <input type="email" id="email" name="email" required>

  <input type="submit" value="Register">
</form>

How it works: the action attribute names where the data is sent and method="post" sends it hidden in the request body. When the user clicks Register, the browser first checks the built-in validation — if the name box is empty, or the email is not in a valid name@example.com shape, it stops the submission and shows a message automatically. Only when both pass is the data sent.

✓Final answer

A <form> containing a required text input for the name, a required type="email" input for the address, and a submit button, as shown in the code above.

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.