1

I am implementing a Booking form where I want the date to be set to default to today . It should also be shown as a placeholder in the input. Is there any way it can be possible in HTML5.

<input type="date" name="from" value="" id="date" class="ajaxField required"/>                  
Farhan9690
  • 47
  • 1
  • 5

1 Answers1

0

I think there is no way to do this using pure HTML, but you can use a simple js script:

HTML:

<head>
<script src="script.js" defer></script>
</head>
<body>
    <form>
        <input id="time">
    </form>
</body>

JS:

const time = document.getElementById("time")
let today = new Date();
time.placeholder=today.toString().slice(4, 10)
muddv
  • 1
  • 2