Skip to content

Latest commit

 

History

History
71 lines (64 loc) · 4.58 KB

n3ba.md

File metadata and controls

71 lines (64 loc) · 4.58 KB

Stars Badge Forks Badge Pull Requests Badge Issues Badge GitHub contributors Visitors

Don't forget to hit the ⭐ if you like this repo.

JavaScript: JS Event & JS Form Validation

Set B

  1. a) addEventListener
  2. c) Both a) and b) are correct.
  3. b) event.preventDefault();
  4. a) To prevent event bubbling.
  5. a) It prevents the default behavior of the link and logs the value of the href attribute.
  6. b) Using the addEventListener method multiple times.
  7. a) It logs the value of the key that was pressed.
  8. a) removeEventListener
  9. a) To access the element on which the event was triggered.
  10. a) It prevents the default behavior of the form submission and logs 'Form submitted' to the console.
  11. a) Check if the input field's value is empty.
  12. a) It adds an error class to the email input if the value does not contain an '@' symbol and logs 'Invalid email address' to the console.
  13. d) All of the above.
  14. a) To detect changes to an input element's value.
  15. a) It logs true or false based on whether the checkbox is checked or not.
  16. a) Use the event.preventDefault() method inside the form's submit event handler.
  17. a) To detect when an element gains focus.
  18. c) It sets a custom validity state on the password input based on its length.
  19. a) Use the dispatchEvent method.
  20. a) To detect when a key is released after being pressed inside an input element.
  21. b) It logs 'Form is invalid' to the console when the form is submitted with invalid inputs.
  22. c) Both a) and b) are correct.
  23. a) To detect changes to an input element's value.
  24. a) It logs the selected value of the select element.
  25. c) Both a) and b) are correct.
  26. a) To detect when a form is submitted.
  27. a) It logs true or false based on whether the checkbox is clicked or not.
  28. c) Both a) and b) are correct.
  29. a) It logs the length of the text in the textarea whenever it changes.
  30. c) Both a) and b) are correct.
  31. a) To detect when the mouse enters an element.
  32. a) It logs 'Mouse entered the button' to the console when the mouse enters the button.
  33. c) Both a) and b) are correct.
  34. a) To detect when the mouse leaves an element.
  35. a) It logs 'Mouse left the link' to the console when the mouse leaves the link.
  36. c) Both a) and b) are correct.
  37. c) To detect when the mouse moves inside an element.
  38. a) It logs 'Mouse moved inside the element' to the console when the mouse moves inside the element.
  39. c) Both a) and b) are correct.
  40. a) To detect when the mouse leaves an element.
  41. a) It logs 'Mouse left the element' to the console when the mouse leaves the element.
  42. a) Use the includes() method of the textarea element's value.
  43. a) To detect when a key is pressed inside an input element.
  44. a) It logs the value of the key that was pressed.
  45. a) Use the match() method with a regular expression that matches uppercase letters.
  46. a) To detect when a key is pressed inside an input element.
  47. a) It logs the value of the key that was pressed.
  48. a) Check if the textarea element's value is an empty string.
  49. a) To detect when a key is released after being pressed inside an input element.
  50. a) It logs the value of the key that was released.

Contribution 🛠️

Please create an Issue for any improvements, suggestions or errors in the content.

You can also contact me using Linkedin for any other queries or feedback.

Visitors