The code is as follows:
Javascipt Code:
<script type= "Text/javascript" >
var reg = new RegExp ("^ (//d{6}) ((//d{2}) | ( D{4})) (//d{2}) (//d{2}) ((//d{4}) | ( D{3}X) | (//d{3})) $");
function Compute () {
var id = $ ("id");
var birth = $ ("Birth");
var idv = Id.value;
if (!reg.test (IDV)) {
Alert ("Sorry, your input format is incorrect.") ");
Id.focus ();
Return
}
var year = Idv.replace (Reg, "$");
if (year.length==2) {
Year= "+year";
}
var month = Idv.replace (Reg, "$");
var day = Idv.replace (Reg, "$");
Birth.value = "" + year + "years" + month + "Month" + Day + "days";
}
function $ (ID) {
return document.getElementById (ID);
}
</script>
Body:
<body>
<form
ID Number
<input type= "text" id= "id" />
<input type= "button" value= "calculation" onclick= "compute ()"/><br/>
Date of birth
<input type= "text" id= "birth" />
</ Form>
</body>