Which HTML should you use?

Posted by: Pdfprep Category: 70-480 Tags: , ,

You are developing a customer web form that includes the following HTML.

<input id="txtValue"/>

You need to change the HTML markup so that customers can enter only a valid three-letter country code.

Which HTML should you use?
A . <input id="txtValue" type="code" />
B . <input id="txtValue" type="text" pattern=" [A-Za-z] {3}" />
C . <input id="txtValue" type="text" required="required"/>
D . <input id="txtValue" type="country" />

Answer: B

Explanation:

HTML <input> pattern Attribute

The pattern attribute specifies a regular expression that the <input> element’s value is checked against.

Example

An HTML form with an input field that can contain only three letters (no numbers or special characters):

<form action="demo_form.asp">

Country code: <input type="text" name="country_code"

pattern="[A-Za-z]{3}" title="Three letter country code">

<input type="submit">

</form>

Reference: HTML <input> pattern Attribute

http://www.w3schools.com/tags/att_input_pattern.asp

Leave a Reply

Your email address will not be published.