A.16. Using HTML Forms

The FORM Element

  • Usual form:

    <FORM ACTION="URL" ...> ... </FORM>
    
  • Attributes: ACTION (required), METHOD, ENCTYPE, TARGET, ONSUBMIT, ONRESET, ACCEPT, ACCEPT-CHARSET

Textfields

  • Usual form:

    <INPUT TYPE="TEXT" NAME="..." ...> (no end tag)

  • Attributes: NAME (required), VALUE, SIZE, MAXLENGTH, ONCHANGE, ONSELECT, ONFOCUS, ONBLUR, ONKEYDOWN, ONKEYPRESS, ONKEYUP

  • Different browsers have different rules regarding the situations where pressing Enter in a textfield submits the form. So, include a button or image map that submits the form explicitly.

Password Fields

  • Usual form:

    <INPUT TYPE="PASSWORD" NAME="..." ...> (no end tag)

  • Attributes: NAME (required), VALUE, SIZE, MAXLENGTH, ONCHANGE, ONSELECT, ONFOCUS, ONBLUR, ONKEYDOWN, ONKEYPRESS ...

Get Core Servlets and JavaServer Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.