I've been working on a project where I'm developing a website using JavaScript, HTML, and CSS to search for movies and purchase tickets. While the basic functionalities are working fine, I'm encountering some challenges with form validation.
Here's how the site functions:
- Users search for a movie title and poster image, which is retrieved from the omdb API
- Users input their details in a form (name, email, ticket quantity)
- Users click "order tickets" and see a thank you message, along with the order history being displayed
If a user fails to enter their name, email, or ticket quantity, the order should not be added to the history. Additionally, even if the page reloads unexpectedly, the order history should persist.
To ensure users provide the necessary information, I have included the required
attribute in each field as shown below:
<section id="Order-Form" style="display: none;">
<h2>Order your tickets</h2>
<ul>
<li>
<label for="User">Please enter your name:</label>
<input type="text" id="User" value="" required>
</li>
<li>
<label for="Email">Please enter your E-mail address:</label>
<input type="email" id="Email" value="" required>
</li>
<li>
<label for="Ticket-Amount">Amount of tickets: (You can order a maximum of 8 tickets)</label>
<input type="number" id="Ticket-Amount" value="" min="1" max="8" required>
</li>
Below is the code snippet for my page
...
My goal is to enforce completion of the "user, email, and ticket amount" fields while limiting ticket orders to a maximum of 8. I suspect that the lack of logic in the function hookupEventHandlers()
may be causing this issue. Can someone assist me in integrating more validation logic into it?