(function() {
$('#submit').on('click', function(){
var date = new Date($('#date-input').val());
day = date.getDate();
month = date.getMonth() + 1;
year = date.getFullYear();
alert([day, month, year].join('/'));
});
})();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="date" id="date-input" required />
<button id="submit">Submit</button>
In input date, format should be 01-mar-23
even if the user type in this format 01-03-23
The required format be 01-mar-23
3
Answers
You can use this Format for a date to convert month to string
You can also get the month name in your date format like this,
The date with month in string format you are asking for is not supported in browser native datepickers.
Although, you can achieve the format you need by seperating the day, month and year in 3
select boxes
, where user can select from the month dropdown, and in that we can pass options according to our requirement like,