Question 2
You are developing a customer web form that includes the following HTML.
<input id = "txtValue" />
A customer must enter a value in the text box prior to submitting the form.
You need to add validation to the text box control.
Which HTML should you use?
<input id="txtValue" type="text" required="required"/>
<input id="txtValue" type="text" pattern="[A-Za-z]{3}" />
<input id="txtValue" type="required" />
<input id="txtValue" type="required" autocomplete="on" />
Correct answer: A
Explanation:
Definition and Usage The required attribute is a boolean attribute. When present, it specifies that an input field must be filled out before submitting the form. Example An HTML form with a required input field:<form action="demo_form.asp"> Username: <input type="text" name="usrname" required /> <input type="submit" /> </form> Username: <input type="text" name="usrname" required />Reference: HTML <input> required Attributehttp://www.w3schools.com/tags/att_input_required.asp
Definition and Usage
The required attribute is a boolean attribute.
When present, it specifies that an input field must be filled out before submitting the form.
Example
An HTML form with a required input field:
<form action="demo_form.asp">
Username: <input type="text" name="usrname" required />
<input type="submit" />
</form>
Username: <input type="text" name="usrname" required />
Reference: HTML <input> required Attribute
http://www.w3schools.com/tags/att_input_required.asp