I need to change a South African ID number to the date of birth (DOB)dd/mm/yyyy using javascript
example of ID Number - 0203185149088.
My code gives it as 18/03/02 instead of 18/03/2002 and if ID No is 6202185155087 then i get 18/02/62 and not 18/02/1962
The years before 2000 and after needs to be added please
dd/mm/yyyy
Please assist
javascript
I got this code somewhere but cannot add it
example of ID Number - 0203185149088.
My code gives it as 18/03/02 instead of 18/03/2002 and if ID No is 6202185155087 then i get 18/02/62 and not 18/02/1962
The years before 2000 and after needs to be added please
dd/mm/yyyy
Please assist
Code:
<form> <input type="text" name="idno" id="idno" value="" placeholder="ID Number" onkeyup="dateOfBirthsum();" /> <input type="text" name="dob" id="dob" placeholder="birthdate"/> </form>
Code:
<script>
function dateOfBirthsum()
{ var idnumInput = document.getElementById('idno').value;
var dateDay = idnumInput.substring(4,6);
var dateMonth = idnumInput.substring(2,4);
var dateYear = idnumInput.substring(0,2);
var result = dateDay + "/" + dateMonth + "/" + dateYear;
document.getElementById('dob').value = result;
}
</script>
I got this code somewhere but cannot add it
Code:
var year = id_number.substr ( 0 , 2 );
var nowYearNotCentury = currentTime.getFullYear() + '';
nowYearNotCentury = nowYearNotCentury.substr(2,2);
if (year <= nowYearNotCentury){
date = '20' + year+ "-" + id_number.substr(2, 2) + "-" + id_number.substr(4, 2);
} else {
date = '19' + year+ "-" + id_number.substr(2, 2) + "-" + id_number.substr(4, 2);
}//end if
Comment