几个JS判断问题
问题一部分代码:问题在于判断不执行
var time=window.document.form["equip.buytime"];
   	var r = time.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
   if(r==null)
   	{
   	alert("请以2000-10-10格式输入时间");
   	return false;
   	}
   var price=window.document.form["equip.price"];
   	re=/^(([1-9]\d*)|0)(\.\d{1,2})?$/
   if(!re.test(price))
   	{
   	alert("请以2000.00格式输入价格");
   	return false;
   	}
<th align="center" valign="middle" nowrap="nowrap">购买时间:<br /></th>
<td align="left"  valign="middle"><input name="equip.buytime" type="text" size="50"/></td>
<td  valign="middle">2009-10-10</td>
</tr>
<tr>
<th align="center" valign="middle" nowrap="nowrap">价格:<br /></th>
<td align="left"  valign="middle"><input name="equip.price" type="text" size="50"/></td>
<td  valign="middle">*2000.00 保留小数点后两位</td>
</tr>
问题二部分代码:问题也是不能执行 而且从else以后的一个if子句在eclipse中居然变成了绿色 而一模一样的判断写在别的页面没有问题
  <script type="text/javascript">
   function checkform()
   {
   if(window.document.form["staff.staffid"].value.length==0)
   	{
   	alert("员工编号不能为空");
   	return false;
   	}
   else
   if(window.document.form["staff.staffname"].value.length==0)
   	{
   	alert("姓名不能为空");
   	return false;
   	}
   }</script>
   <style type="text/css">
<form name="form" action="AddStaff.action" method="post" onsubmit="return checkform()">
<table width="25%" align="center">
<tbody>
<tr>
<th align="center" valign="middle" nowrap="nowrap"><br/>员工编号:<br/><br/></th>
<td><input type="text" name="staff.staffid"/></td></tr>
<tr>
<th align="center" valign="middle" nowrap="nowrap"><br/>姓名:<br/><br/></th>
<td><input type="text" name="staff.staffname"/></td></tr>
<tr>
------解决方案--------------------
window.document.form["equip.buytime"];
写法有问题
应改为 document.getElementsByName("equip.buytime")[0].value;
or 通过 id 获取
------解决方案--------------------楼主这就是js的问题,在不同浏览器有不同的标准,document.getElementsByName("equip.buytime")[0].value;应该可以
------解决方案--------------------
错误一箩筐
HTML code
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Text</title>
    </head>
    <body>
        <form>
            <table>
                <tr>
                    <th align="center" valign="middle" nowrap="nowrap">购买时间:</th>
                    <td align="left" valign="middle"><input name="equip.buytime" type="text" size="50"/></td>
                    <td valign="middle">2009-10-10</td>
                </tr>
                <tr>