a form with date filter in javascript

<form>
    <label for="start-date">Start Date:</label>
    <input type="date" id="start-date" name="start-date">
    <label for="end-date">End Date:</label>
    <input type="date" id="end-date" name="end-date">
    <input type="submit" value="Apply">
</form>
259 chars
8 lines
form {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

label {
    margin-right: 10px;
}

input[type="submit"] {
    border: none;
    background-color: #007bff;
    color: #fff;
    padding: 5px 10px;
    cursor: pointer;
}
300 chars
20 lines
index.tsx
const form = document.querySelector('form');

form.addEventListener('submit', e => {
    e.preventDefault();
    const startDate = document.querySelector('#start-date').value;
    const endDate = document.querySelector('#end-date').value;
    
    // Do something with the selected dates, like send an API request, process data, etc.
});
338 chars
10 lines

This code creates a basic form with two date inputs, a submit button and applies some simple styling on the form. The JavaScript code listens for a submit event on the form, prevents the default form submission behavior, and retrieves the selected start and end dates. You can use or modify this code to suit your specific needs.

gistlibby LogSnag