PrepAway - Latest Free Exam Questions & Answers

You need to prevent users from entering specific charac…

You develop an HTML5 webpage. You have the following HTML markup:
<input type=”text” id=”username” />
You need to prevent users from entering specific characters into the username field.
What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Using the keyup event, add an anonymous function that returns true when a specific character keycode
value is determined.

B.
Using the change event, add an anonymous function that returns true when a specific character keycode
value is determined.

C.
Using the keydown event, add an anonymous function that returns false when a specific character keycode
value is determined.

D.
Using the change event, add an anonymous function that returns false when a specific character keycode
value is determined.

Explanation:
The change event is fired for <input>, <select>, and <textarea> elements when a change to the element’s value
is committed by the user.
Use the change event and an anonymous function to detect illegal specific characters in the input.

3 Comments on “You need to prevent users from entering specific charac…

  1. dedy says:

    onchange occurs when the input element loses focus and it will not preventusers from entering specific char.

    keydown event can prevent a specific char when it returns false.

    The answer should be C.




    4



    0

Leave a Reply