You need to prevent users from entering specific characters into the username field

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?

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:



Leave a Reply 7

Your email address will not be published. Required fields are marked *


YoYo

YoYo

Why D is not the answer?

Return False to prevent from entering specific chars?

nex-54

nex-54

yes, i think d is correct

anii

anii

Please explain. How would the code be in this case? Prove that this is right..

stenly

stenly

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