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
解决方案 »
- 页面乱码的问题
- 现在我要使用网上的数据来生成页面,生成柱形图。
- 关于rich:dataList
- 求教,我的index.jsp想阻止手机访问
- 急!???????????????HTTP Status 404 - /FCKeditor/editor/filemanager/browser/default/browser.htm错误
- javax.servlet.ServletException: No getter method for property Admin_Name of bean org.apache.struts.taglib.html.BEAN
- 怎样用JSP实现书签效果
- applet与servlet之间的对象传递问题?JspSmart上载模块问题?请施以援手!
- JSP中传中文参数的问题
- 使用gson提取 json数组中的值
- 那位高手能把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>