An HTML form needs meaningful labels, correctly named controls and a clear submission action. Native validation can catch some input mistakes in the browser, but it cannot enforce the server's security rules. Interview answers should separate user help from trustworthy backend validation.

This example is a fictional subscription form. The action is illustrative; it is not a request to submit an email to a real service.

Which attributes matter to a basic form?

<form action="/subscribe" method="post">
  <label for="reader-email">Email address</label>
  <input id="reader-email" name="email" type="email"
         autocomplete="email" required>
  <button type="submit">Subscribe</button>
  <button type="button">Show privacy details</button>
</form>

The label identifies the control through its ID. The name identifies the value included in form submission. These are different jobs: an input can be visibly labeled yet fail to send the expected field if its name is missing.

The buttons have explicit types. The second is not supposed to submit the form. Its behavior would need implementation, but setting its type prevents it from unintentionally becoming the submit action while that behavior is added.

Is a placeholder an adequate label?

It is not a reliable replacement for a persistent label. Placeholder text can disappear as someone types, and example text is not the same as a clear name for the field. Keep the visible label and use supporting text when a format or purpose needs explanation.

For a more complex form, associate instructions and error messages with the relevant control. Avoid a design that communicates an error only through a color change or expects the user to remember text that has vanished.

What does type=email validate?

It enables browser behavior for the email input type, including relevant constraint validation. It does not prove that the address exists, belongs to the person submitting the form or can receive a message. Those are different checks with different purposes.

The required attribute also checks a constraint; it is not a guarantee that a legitimate user completed the form. A caller can send a request without using this HTML at all. The server must independently validate the request and apply its own authorization and abuse controls.

What is the difference between disabled and readonly?

A disabled form control generally does not participate in form submission. A read-only control can still be submitted, where the control type supports that attribute. Neither attribute should be treated as protection against a caller changing request data.

Suppose a form displays an account ID. Making the field read-only may prevent ordinary editing in that interface, but the server should obtain or validate account ownership through trusted context. Do not use a UI attribute as the source of authority.

Can a program submit a form without normal validation?

Yes. Different submission paths have different behavior. The form's submit method is not equivalent to a user activating the submit button; requestSubmit follows the normal submission process more closely. Also, validation can be deliberately disabled in markup. Check the exact API and intended behavior before making a universal claim.

In a practical interview, test the user path: focus the field, enter an invalid value and activate the submit button. Then test a valid value. Keep the submission from reaching a real service while running the example.

What should a useful test cover?

  • The visible label selects or names the correct control.
  • An empty required value fails native constraint validation.
  • A clearly malformed email fails the email constraint.
  • The non-submit button does not submit.
  • The backend rejects an invalid direct request independently.

The last check belongs to a server test, not a claim you can establish from this HTML fragment. Explaining that boundary is often more valuable than listing additional form attributes.

References and next practice

developer.mozilla.org — html forms

Browse interview topics · Practise a question in Interview Challenge · How to Answer Technical Interview Questions Out Loud