0

I am trying to change the min date message from "please select a value that is not earlier than 2018-10-02" to something like "please select a value that is not earlier than 02-10-2018".
enter image description here
Is it possible to change the date format of that message?

My code:

<input style="font-family: Arial;"
       class="date_input"
       type="date"
       id="dates" name="dates"
       min="<?php echo $today;?>"
       value="<?php echo $today;?>" />
J.vee
  • 625
  • 1
  • 7
  • 26

1 Answers1

1

You can use oninvalid:

<input style="font-family: Arial;"
       class="date_input"
       oninvalid="setCustomValidity('Some message about minimum date')
       type="date"
       id="dates" name="dates"
       min="<?php echo $today;?>"
       value="<?php echo $today;?>" />
Maor Refaeli
  • 2,222
  • 2
  • 20
  • 32
  • inline js should be avoided as is bad practice that leads to hard-to maintain code – treyBake Oct 02 '18 at 09:02
  • 3
    I don't think this single line is going to become a maintenance problem... this is also the shortest way to demonstrate the issue in an answer. @ThisGuyHasTwoThumbs Your somewhat nit picking here. – Liam Oct 02 '18 at 09:03
  • 1
    @Liam true, a single line won't but if OP doesn't know it's bad practice and uses it for every input ... it quickly adds up – treyBake Oct 02 '18 at 09:04