I can only use type="text" and I'm planning to get the format DD/MM/YYYY as the user types in the input field.
So far, I manage to get DD/MM/YY/Y. The year should be in YYYY format. How do I go about this?
$('[data-type="date"]').keyup(function() {
var value = $(this).val();
value = value.replace(/\D/g, "").split(/(?:([\d]{2}))/g).filter(s => s.length > 0).join("/");
$(this).val(value);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<input type="text" pattern="[0-9]*" data-type="date" maxLength="10" id="date" class="form-control" placeholder="DD/MM/YYYY">