I got this working however, it need to limit the parts of the text input. For instance, I have to limit DD
to allow upto 31, MM
to limit upto 12 and limit YYYY
from 1900 to 2018
Any idea how to go about this?
$('[data-type="dateofbirth"]').mask('00/00/0000');
function submitBday1() {
var Q4A = "";
var Bdate = document.getElementById('bday1').value;
var darr = Bdate.split('/');
var temp = darr[0];
darr[0] = darr[1];
darr[1] = temp;
var fmtstr = darr.join('/');
var Bday = +new Date(fmtstr);
Q4A += ~~((Date.now() - Bday) / (31557600000));
var theBday = document.getElementById('resultBday1');
theBday.innerHTML = Q4A;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.15/jquery.mask.min.js"></script>
<input type="text" pattern="[0-9]*" data-type="dateofbirth" maxLength="10" id="date" class="form-control" placeholder="DD/MM/YYYY">