<html>
<head>
<script >
//方法的命名不能是关键字 否则会出现错误
//获得PlateNum焦点
function Pricefocus()
{
//把层隐藏
document.getElementById("divPrice").style.display="none";
document.form1.txtPrice.style.backgroundColor="yellow";
} //失去PlateNum焦点
function Priceblur()
{
//alert("车牌号码不能为空");
//让层可见
var p1=/^[1-9][0-9]{3,6}$/;
var p2=/^[1-9][0-9]{3,6}\.\d+$/;
if(!p1.test(document.form1.txtPrice.value)&&!p2.test(document.form1.txtPrice.value))
{
document.getElementById("divPrice").style.display="block";
document.getElementById("divPrice").innerHTML="<font color='red' size='1'>新车购置价只能是大于一千的整数或小数</font>";
document.form1.txtPrice.style.backgroundColor="red";
}else{
document.form1.txtPrice.style.backgroundColor="green";
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="1.html" >
<table width="567" height="39" border="1">
<tr>
<td width="129">新车购置价 </td>
<td width="170"><input type="text" name="txtPrice" onfocus="Pricefocus()" onblur="Priceblur()">
</td>
<td width="131"><div id="divPrice"></div></td>
<td width="89"><label>
<input type="submit" name="Submit" value="提交">
</label></td>
<td width="14"> </td>
</tr>
</table>
</form>
</body>
</html>
<head>
<script >
//方法的命名不能是关键字 否则会出现错误
//获得PlateNum焦点
function Pricefocus()
{
//把层隐藏
document.getElementById("divPrice").style.display="none";
document.form1.txtPrice.style.backgroundColor="yellow";
} //失去PlateNum焦点
function Priceblur()
{
//alert("车牌号码不能为空");
//让层可见
var p1=/^[1-9][0-9]{3,6}$/;
var p2=/^[1-9][0-9]{3,6}\.\d+$/;
if(!p1.test(document.form1.txtPrice.value)&&!p2.test(document.form1.txtPrice.value))
{
document.getElementById("divPrice").style.display="block";
document.getElementById("divPrice").innerHTML="<font color='red' size='1'>新车购置价只能是大于一千的整数或小数</font>";
document.form1.txtPrice.style.backgroundColor="red";
}else{
document.form1.txtPrice.style.backgroundColor="green";
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="1.html" >
<table width="567" height="39" border="1">
<tr>
<td width="129">新车购置价 </td>
<td width="170"><input type="text" name="txtPrice" onfocus="Pricefocus()" onblur="Priceblur()">
</td>
<td width="131"><div id="divPrice"></div></td>
<td width="89"><label>
<input type="submit" name="Submit" value="提交">
</label></td>
<td width="14"> </td>
</tr>
</table>
</form>
</body>
</html>
解决方案 »
- 请教高手!jmx在tomcat中的作用??
- Java servlet问题,初学请教~~
- JAVA EE WEB
- Struts2 问题 -include标签
- servlet如何显示指定图片???
- struts标签<bean:write>的问题.
- 看到好多兄弟都在找weblogic8的配置方法,我找到了一个《快速配置weblogic8_X的应用目录》,拿来和大家分享。希望兄弟们捧场。
- ejb项目你通常采用哪种方式调用?
- 为什么我在weblogic里配jdbc,用weblogic.mssqlserver4可以,而用微软的jdbc就不行。
- s:iterator无法将LIST里面的对象在jsp显示出来
- 关于在项目中嵌入网银功能
- j2ee面试时,那些方面的知识重要
}楼主,注意你的结帖
你也可以自己写function的验证,不过这样写就比较麻烦了。