<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<style type="text/css">
#errInfo{
color:red;
font-weight:bold;
}
</style>
<script language="javascript">
function testAge()
{
var key=event.keyCode;
var err=document.getElementById("errInfo");
if(key>=48&&key<=57){
err.innerText="";
return true;//允许录入
}
else{
err.innerText="年龄只能输入数字!";
return false;//阻止录入,放弃掉本次录入
}
}
function upper(who){
who.value=who.value.toUpperCase();
/*var lbs=document.getElementsByTagName("label");
for(i=0;i<lbs.length;i++)
{
if(lbs.item(i).for=="txtCountryErr")
{
lbs.item(i).innerHTML="";
}
}*/
var lb=document.getElementById("txtCountryErr");
lb.innerHTML=who.value;
}
</script>
<body>
<form id="form1" name="form1" method="post" action="">
<p>
<label for="txtUID">帐号</label>
<input name="txtUID" type="text" id="txtUID" maxlength="8" /> </p>
<p>
<label for="txtAge">年龄</label>
<input type="text" name="txtAge" id="txtAge" onkeypress="return testAge()"/> </p>
<p>
<label for="txtHeight">身高</label>
<input type="text" name="txtHeight" id="txtHeight" onkeypress="testHeight()"/> </p>
<p>
<label for="txtCountry">国籍</label>
<input type="text" name="txtCountry" id="txtCountry" onkeyup="upper(this)"/>
<label for="txtCountryErr" id="txtCountryErr"></label>
</p>
<p>
<input type="button" name="button" id="button" value="注册" /> </p>
<p id="errInfo"> </p>
</form>
</body>
</html>
Powered by ddoss.cn 12.0
©2015 - 2024 ddoss
渝公网安备50011302222260号 渝ICP备2024035333号 【实验平台安全承诺书】 小绿叶技术社区,优化网络中,点击查看配置信息
您的IP:192.168.122.82,2024-10-10 18:32:38,Processed in 0.02714 second(s).