This project creates a simple countdown timer using HTML, CSS, and JavaScript. The timer allows users to input a number of seconds, click a button to start the countdown, and displays the remaining time in a styled div. The design is enhanced with CSS for a modern, clean look.
- HTML: Structure of the timer interface, including input, button, and display elements.
- CSS: Adds visual styles such as gradients, hover effects, and responsive layouts.
- JavaScript: Implements the timer logic, handles user interactions, and dynamically updates the DOM.
- A text input field for entering the countdown duration in seconds.
- A button to start or reset the countdown.
- The timer dynamically decreases the displayed number every second.
- Proper handling of restarting the timer if the button is pressed again during an active countdown.
- If an invalid input is given (e.g., negative number or non-numeric value), the script defaults to "0" and prompts users to enter a valid value.
- Enter the desired countdown duration in seconds into the input field.
- Press the "Start" button to begin the countdown.
- The number displayed in the large div starts from the input value and decreases by 1 every second until it reaches 0.
- If the "Start" button is pressed again during the countdown, the current countdown is canceled, and a new one begins with the updated input value.