Hi guys I'm creating an application for a region where date format is only in DD/MM/YYYY while the default input type date format in MM/DD/YYYY
Jquery CDN added
Bootstrap CDN added
<form>
<input type='date' id='date' name='date' required>
<input type='submit'>
</form>
I can do this by placing a placeholder of 'dd/mm/yyyy'
in input because value is in format of yyyy-mm-dd
that don't bother me but that require is creating problem. When a user gives wrong input in mm/dd/yyyy
format it gives an error that date is incorrect so placing a placeholder will not work in this required case.
how can i change it to dd/mm/yyyy
so it can work with required.
Instead of this use jquery's Datepicker.IN Jquery's Datepicker You can set any date Format You want.
Add this code in script tags at the end of body
<script>$('#date').datepicker({ dateFormat: 'dd-mm-yy' }).val();</script>
Just Add These Cdn's in head section in your code
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>