日期:2014-05-17  浏览次数:20829 次

js代码在改变焦点的时候出现方法is not fond ,为什么呢?
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%@ page import="com.bean.Triangle" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>My JSP 'triangle.jsp' starting page</title>
   
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function checkbiana(){
var sidea = myform.sideA.value;
var reg = /^\d+$/
if(reg.test(sidea)))
{
document.getElementById("a").innerHTML="输入的数据合法";
return true;
}
else{

document.getElementById("a").innerHTML="输入的数据不合法";
document.getElementById("a").style.color="red";
return false;
}
}

function checkbianb(){
var sideb = myform.sideB.value;
var reg = /^\d+$/
if(reg.test(sideb)))
{
document.getElementById("b").innerHTML="输入的数据合法";
return true;
}
else{

document.getElementById("b").innerHTML="输入的数据不合法";
document.getElementById("b").style.color="red";
return false;
}
}

function checkbianc(){
var sidec = myform.sideC.value;
var reg = /^\d+$/
if(reg.test(sidec)))
{
document.getElementById("c").innerHTML="输入的数据合法";
return true;
}
else{
document.getElementById("c").innerHTML="输入的数据不合法";
document.getElementById("c").style.color="red";
return false;
}
}

function cleck(){

if(checkbiana()&&checkbianb()&&checkbianc())
{
return true;
}
else{
alert("输入数据错误请重新输入");
return false;
}
}

</script>
  </head>
  
  <body>
  <form action="" name="myform" method="post" onsubmit="return cleck();"> 
  输入三角形的边A:<input type="text" name="sideA"/><span id="a">请输入数字</span><br/>
 
  输入三角形的边B:<input type="text" name="sideB" onfocus="checkbiana()"/><span id="b">请输入数字</span><br/>
  输入三角形的边C:<input type="text" name="sideC" onfocus="checkbianb();" /><span id="c">请输入数字</span><br/>
  <input type="submit" value="提交" />
  </form>
  <jsp:useBean id="triangle" class="com.bean.Triangle"></jsp:useBean>
  <jsp:setProperty property="*" name="triangle"/>
  边A的长度是<jsp:getProperty property="sideA"