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?

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 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.



Leave a Reply 3

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


Mkool

Mkool

C is correct option:
from other dump:
stenly
June 30, 2017 at 8:32 pm
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

CasiProgramoMEXAPOWA

CasiProgramoMEXAPOWA

The correct answer is C

S

S

I also think C is the correct answer.