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.
Explanation:
The answer is Key Down. https://jsfiddle.net/66c9e1Lf/
0
0
No, the answer is correct. Key Down event will not work if we paste value using mouse right click (from buffer). B is correct – http://stackoverflow.com/questions/3042120/in-javascript-event-handling-why-return-false-or-event-preventdefault-and
0
0
but change event does not prevent user input
0
0
Why D is not the answer?
Return False to prevent from entering specific chars?
0
0
yes, i think d is correct
0
0
Please explain. How would the code be in this case? Prove that this is right..
0
0
question says preventing, change event cannot prevent any char not being inserted via keyboard as is demonstrated in created example from Hawgie https://jsfiddle.net/66c9e1Lf/
but nothing is mention about coping and pasting – good to point this use case but i dont think should be addressed in any answer
C is correct
1
0