nerdexam
CIW

1D0-720 · Question #92

What is the function of the pattern attribute in HTML5 forms?

The correct answer is A. To specify a regular expression the form input field's value must match. Option A is correct because the HTML5 pattern attribute accepts a JavaScript regular expression (without enclosing slashes) that the input's value must fully match before the form submits - for example, pattern="[A-Za-z]{3}" requires exactly three letters. Option B is wrong…

Advanced HTML5 Features

Question

What is the function of the pattern attribute in HTML5 forms?

Options

  • ATo specify a regular expression the form input field's value must match.
  • BTo define a specific color pattern for the input field.
  • CTo set a default value for the input field.
  • DTo pattern the input field with specific data from a database.

How the community answered

(26 responses)
  • A
    88% (23)
  • B
    4% (1)
  • C
    8% (2)

Explanation

Option A is correct because the HTML5 pattern attribute accepts a JavaScript regular expression (without enclosing slashes) that the input's value must fully match before the form submits - for example, pattern="[A-Za-z]{3}" requires exactly three letters. Option B is wrong because HTML has no concept of a "color pattern" for inputs; colors are handled via CSS. Option C is wrong because default values are set with the value attribute, not pattern. Option D is wrong because HTML form attributes have no built-in mechanism to pull data from a database - that requires server-side or JavaScript logic.

Memory tip: Think of pattern as a gatekeeper - it holds a regex that guards the gate, only letting values through that match the pattern before the form can submit.

Topics

#HTML5 forms#pattern validation#regex#input validation

Community Discussion

No community discussion yet for this question.

Full 1D0-720 Practice