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?
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.
Suggested Answer:B🗳️
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.
That would be incorrect, The keyup/keydown event is sent to an element when the user releases a key on the keyboard. It can be attached to any element, but the event is only sent to the element that has the focus, And the change event is not necessarily fired for each alteration to an element's value.
Meaning it can't be B or D the answer should be A.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
RubyH
Highly Voted 4 years, 9 months agoDreamchaser1980
Most Recent 3 years, 11 months agonlb
4 years, 4 months agoNicolaas
4 years agoruif90
4 years, 4 months agoShiras
4 years, 11 months agobdb1993
5 years agoMushi
5 years, 8 months agomogec39
5 years, 2 months agomogec39
5 years, 2 months ago