Skip to content

Instantly share code, notes, and snippets.

Last active January 25, 2024 23:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ziadoz/36f52e02b07a4530e6194bee20c92300 to your computer and use it in GitHub Desktop.
Select Date Dropdown / Input
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style> {
visibility: hidden;
document.addEventListener('DOMContentLoaded', () => {
const selectEl = document.querySelector('select[name="relative-date"]');
const dateEl = document.querySelector('input[name="exactdate"]');
dateEl.disabled = true;
['load', 'change'].forEach((emit) => {
selectEl.addEventListener(emit, (event) => {
dateEl.disabled = ( !== 'Select Date');
<div class="date-dropdown">
<select name="relative-date">
<option selected></option>
<option>Select Date</option>
<div class="date-input">
<label for="exactdate">Date</label>
<input type="date" name="exactdate" id="date" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment