为什么用JS获取不到信息
html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>注册title>
<script language="javascript">
function btc(){
var idcard;
idcard=document.f.idnumber.value;
var yearbirth=parseFloat(idcard.substring(6,10));
var monthbirth=parseFloat(idcard.substring(10,12));
var daybirth=parseFloat(idcard.substring(12,14));
document.f.year1.value=yearbirth;
document.f.month1.value=monthbird;
document.f.day1.value=daybirth;
}
script>
<style>
*{
margin: 0;
padding: 0;
}
body{
background-size: 100% 700px;
background-repeat: no-repeat;
background-image: url(../imafes/登录注册背景图\(1\).jpg);
}
div{
width: 400px;
height: 500px;
background-color: rgb(129, 168, 213);
margin: auto;
margin-top: 100px;
}
p{
line-height: 4em;
height: 2em;
}
style>
head>
<body>
<div>
<h1 align="center">用户注册界面h1>
<form action="" name="f">form>
<br>
<br>
<p> 用户名:<input type="text" name="user" size="33" placeholder="请输入用户名">p>
<p> 密码:<input type="password" name="password" size="30" placeholder="请输入密码">p>
<p> 姓名:<input name="username" type="text" maxlenth="10" placeholder="请输入姓名" />p>
<p> 性别:<input name="sex" type="radio" value="男" />男
<input name="sex" type="radio" value="女" />女p>
<p> 身份证号:<input name="idnumber" type="text" maxlenth="18" placeholder="请输入身份证号"/>
p><p> <input name="btn" type="button" value="获取身份信息" onclick="btc()">p>
<p> 出生日期:<input type="number" name="year1" min="2000" max="2022" />年
<input type="number" name="month1" min="01" max="12" />月
<input type="number" name="day1" min="01" max="31" />日p>
<p> 联系电话:<input name="username" type="text" maxlenth="30" placeholder="请输入电话"/>p>
<p> 邮箱:<input name="username" type="text" maxlenth="18" placeholder="请输入邮箱"/>p>
<p> 地址:<input name="username" type="text" maxlenth="18" placeholder="请输入地址"/>p>
<p>
<a href="实验二-登录.html" target="_blank" title="注册"><input type="submit" value="注册" align="center">a>a>
form>
div>
body>
html>
建议用jQuery或者原生document.getElenentById