parseInt("abc") // Returns NaN.
parseInt("12abc") // Returns 12.
you should use isNaN to check value of the four input element above first
parseInt("12abc") // Returns 12.
you should use isNaN to check value of the four input element above first
解决方案 »
- MYSQL查询任意一个月的记录
- 汉诺塔问题
- MyEclipse中运行tomcat时出现Source not found for AprEndpoint
- 请教几个代码含义?高手进
- 求助:关于JSP的时间处理及JAVABEAN..
- 使用struts 的LookupDispatchAction 编译出现“Unable to compile class for JSP”错误
- 探讨使用java代码,还是使用标签库实现jsp动态内容显示! 请大家参与讨论^-^
- 请给个树型结构的JAVABEAN
- Jsp 如何实现递归方法调用?
- jsp运行问题,我是菜鸟!
- 那位高手能把tomcat的启动dos窗口贴出来
- 高分寻求apache1.3+tomcat4配置
得用document.form1.T1.value得到值。
另给form加上name属性。
I am a caibird in JavaScript.
<form method="POST" onsubmit="return check();" action="bb1.jsp" name="form1">
在你的Javascript中使用form1来指定form元素:
if (parseInt(form1.T1.value)!= parseInt(form1.T2.value)+parseInt(form1.T3.value)+parseInt(form1.T4.value))
function check()
{
if (parseInt(form1.T1.value)!= parseInt(form1.T2.value)+parseInt(form1.T3.value)+parseInt(form1.T4.value))
{
alert("bu相等!");
return false;
}
return true;
}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>New Page 1</title>
</head>
<body>
<form name=form1 method="POST" onsubmit="return check();" action="bb1.jsp">
<p><input type="submit" value="提交" name="B1" ><input type="reset" value="全部重写" name="B2"><input type="text" name="T1" size="20"><input type="text" name="T2" size="20"><input type="text" name="T3" size="20"><input type="text" name="T4" size="20"></p>
</form>
</body>
</html>
function check() {
var obj=document.forms[0];
if (eval(obj.T1.value)!= eval(obj.T2.value) + eval(obj.T3.value) + eval(obj.T4.value)) {
alert("bu相等!");
return false;
}
return true;
}
</script>