Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
129
rated 0 times [  132] [ 3]  / answers: 1 / hits: 47428  / 7 Years ago, tue, august 1, 2017, 12:00:00

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.


More From » jquery

 Answers
7

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>

[#56901] Saturday, July 29, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lucianom

Total Points: 601
Total Questions: 98
Total Answers: 109

Location: Kenya
Member since Fri, Dec 23, 2022
1 Year ago
lucianom questions
Tue, Feb 22, 22, 00:00, 2 Years ago
Wed, May 5, 21, 00:00, 3 Years ago
Sun, Jan 24, 21, 00:00, 3 Years ago
Sat, Aug 15, 20, 00:00, 4 Years ago
Mon, Jun 22, 20, 00:00, 4 Years ago
;