Contents

Form Events:


What is the purpose of the "onsubmit" event in a form element?
a) It triggers when the form is being submitted.        
b) It fires when the user focuses on an input field.
c) It occurs when the form is reset to its default values.             
d) It activates when the form is loaded in the browser.

a

Explanation: The "onsubmit" event in a form element is triggered when the form is being submitted, typically before the form data is sent to the server for processing.


Which form event is fired when the user presses a key while focused on an input field?
a) onkeydown                     
b) onkeypress
c) onkeyup                           
d) onkeytype

a

Explanation: The "onkeyup" event is fired when the user presses a key while focused on an input field in a form.


Which event is triggered when a user clears the content of an input field in a form?
a) onerase                            
b) onclear
c) onreset                              
d) oninput

d

Explanation: The "oninput" event is triggered when a user clears the content of an input field in a form by either typing or using the delete/backspace key.


Form Methods:


Which method is used to disable a form element, preventing user interaction with it, using JavaScript?
a) element. lock();              
b) element. disable();
c) element. setAttribute ('disabled', 'true');
d) element. disabled = true;

d

Explanation: To disable a form element and prevent user interaction with it using JavaScript, you can use the method.