javascript-forms Flashcards
What event is fired when a user places their cursor in a form control?
“Focus”
What event is fired when a user’s cursor leaves a form control?
“Blur”
What event is fired as a user changes the value of a form control?
The change event occurs when a user changes the value of a form element.
What event is fired when a user clicks the “submit” button within a ?
The submit event fires when the user clicks a submit button ( < button> or < input type= “submit”>) or presses Enter while editing a field (e.g. < input type= “text”>) in a form. The event is not sent to the form when calling the form. submit() method directly.
What does the event.preventDefault() method do?
The preventDefault() method of the Event interface tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be.
What does submitting a form without event.preventDefault() do?
The preventDefault() method cancels the event if it is cancelable, meaning that the default action that belongs to the event will not occur. For example, this can be useful when: Clicking on a “Submit” button, prevent it from submitting a form. Clicking on a link, prevent the link from following the URL.
What property of a form element object contains all of the form’s controls.
The HTMLFormElement property elements returns an HTMLFormControlsCollection listing all the form controls contained in the < form> element. Independently, you can obtain just the number of form controls using the length property.
What property of a form control object gets and sets its value?
What is one risk of writing a lot of code without checking to see if it works so far?
If something goes wrong, you won’t know what caused it.
You wont know what exactly broke
What is an advantage of having your console open when writing a JavaScript program?
You can keep track of what the program is doing, and you can see if the output is correct.