PrepAway - Latest Free Exam Questions & Answers

Which HTML should you use?

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?

PrepAway - Latest Free Exam Questions & Answers

A.
<input id=”txtValue” type=”country”/>

B.
<input id=”txtValue” type=”text” required=”xxx”/>

C.
<input id=”txtVa!ue” type=”text” pattern-” [A-Za-z] {3} “/>

D.
<input id=”txtValuen type=”code” pattern”=”country”/>

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>
HTML <input> pattern Attribute
http://www.w3schools.com/tags/att_input_pattern.asp

One Comment on “Which HTML should you use?

  1. Diezvai says:

    Not a good question – regex symbols “{3}” means one character will repeat three times. Since no county code is made up from one character repeated three times, this question is confusing.




    0



    6

Leave a Reply