- Why is it better to use either trickling or bubbling of events? Why not just give the event to the node on which it was invoked?
- Can you think of one situation where you would want to prevent the browser from submitting a form after a user has clicked on the 'submit' button? How would you achieve this?
Let's say there is an event you want to handle for dozens of similar elements on the page. Without bubbling, you would have to wire the same event handler to every single one of those elements. It's better to enclose the elemements in a parent node and assign the event handler to the parent; the handler will then respond to the event as it bubbles up from each child element.
Form data should be validated on the client side before submitting is allowed. I would write a validateForm() function and set the sumit button as follows: onclick="return validateForm()"
Enter how many numbers you want to add
(between 2 and 10):
(between 2 and 10):
No comments:
Post a Comment