practice10(inputText로 입력받아 생년월일출력).html
801 Bytes
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>practice10</title>
</head>
<body>
<input type="text" name="" value="" id="input1">
<input type="button" name="" value="입력" onclick="call()">
<div id = "div1">
</div>
<script type="text/javascript">
function call(){
// var birth = prompt("생년월일을 입력해주세요","6자리 입력");
var birth = document.getElementById("input1").value;
if(birth!=""){
var temp= document.getElementById("div1");
var a = birth.substr(0,2);
var b = birth.substr(2,2);
var c = birth.substr(4,2);
//temp.innerHTML = birth.length;
temp.innerHTML = "생일:19"+a+"년 "+b+"월 "+c+"일";
}
}
</script>
</body>
</html>