<script type="text/javascript">
function checkInput(){
var startDate = document.getElementById("d11").value;
var node = document.getElementById("d12").value;
var endDate = document.getElementById("d13").value;
var phase = document.getElementById("d14").value;

alert("node:" + node+"||");
alert("phase:" + phase+"||");
alert(startDate > endDate);
if(startDate =="" || null == startDate){
alert("请输入起始日期");
return;
}
if(endDate =="" || null == endDate){
alert("请输入截止日期");
return;
}
if(startDate < endDate){
alert("截止日期不能小于起始日期");
return;
}
if(node =="" || null == node){
alert("请输入节点号");
return;
}
if(phase =="" || null == phase){
alert("请输入相位");
return;
}
}
</script>
为什么不执行????

解决方案 »

  1.   

    代码上看没有问题 把你的html相关代码晒出来~~~
      

  2.   

    <%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
      <base href="<%=basePath%>">
    <style type="text/css">
    .query {
    width: 50px;
    height: 50px;
    }
    .select {

    }
    .textArea {
    width: 1250px;
    height: 200px;
    align: center;
    }
    </style>
    <script type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
    </head>
    <script type="text/javascript">
    function checkInput(){
    var startDate = document.getElementById("d11").value;
    var node = document.getElementById("d12").value;
    var endDate = document.getElementById("d13").value;
    var phase = document.getElementById("d14").value;

    alert("node:" + node+"||");
    alert("phase:" + phase+"||");
    alert(startDate > endDate);
    if(startDate =="" || null == startDate){
    alert("请输入起始日期");
    return;
    }
    if(endDate =="" || null == endDate){
    alert("请输入截止日期");
    return;
    }
    if(startDate < endDate){
    alert("截止日期不能小于起始日期");
    return;
    }
    if(node =="" || null == node){
    alert("请输入节点号");
    return;
    }
    if(phase =="" || null == phase){
    alert("请输入相位");
    return;
    }
    }
    </script>
    <body bgcolor="#F0F0F0">
    <fieldset>
    <fieldset>
    <legend>查询条件</legend>
    <div align="center">
    <form action="queryInfo.do" method="post" id = "form1">
    <table class="select">
    <tr>
    <td>
    <table>
    <tr>
    <td>查询日期从&nbsp;&nbsp;<input id="d11" name="startDate" type="text" onClick="WdatePicker()"/></td>
    <td>&nbsp;&nbsp;节点&nbsp;&nbsp;<select name="node">
    <option value="Node1">  节点1  </option>
    <option value="Node2">  节点2  </option>
    <option value="Node3">  节点3  </option>
    <option value="Node4">  节点4  </option>
    </select>
    </td>
    </tr>
    <tr>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;到&nbsp;&nbsp;<input id="d13" name="endDate" type="text" onclick="WdatePicker()"/></td>
    <td>&nbsp;&nbsp;相位&nbsp;&nbsp;<select name="phase">
    <option value="1">  A相位  </option>
    <option value="2">  B相位  </option>
    <option value="3">  C相位  </option>
    </select></td>
    </tr>
    </table>
    </td>
    <td align="right">
    <input type="submit" class="query" name = "submit" value="查询" onclick="checkInput()"/>
    </td>
    </tr>
    </table>
    </form>
    </div>
    </fieldset>
    <br/>
    <fieldset>
    <legend>查询结果</legend>
    <div align="center">
    <table>
    <tr>
    <td>
    <input class="textArea" type="textArea" name="resultSet"/>
    </td>
    </tr>
    </table>
    </div>
    </fieldset>
    </fieldset>
    </body>
    </html>
      

  3.   

    用google搜一下JS验证代码吧,多的很。
      

  4.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
      <base href="<%=basePath%>">
    <style type="text/css">
    .query {
    width: 50px;
    height: 50px;
    }
    .select {}
    .textArea {
    width: 1250px;
    height: 200px;
    align: center;
    }
    </style></head>
    <script type="text/javascript">
    function checkInput(){
    var startDate = document.getElementById("d11").value;
    var node = document.getElementById("d12").value;
    var endDate = document.getElementById("d13").value;
    var phase = document.getElementById("d14").value;alert("node:" + node+"||");
    alert("phase:" + phase+"||");
    alert(startDate > endDate);
    if(startDate =="" || null == startDate){
    alert("请输入起始日期");
    return false;
    }
    if(endDate =="" || null == endDate){
    alert("请输入截止日期");
    return false;
    }
    if(startDate < endDate){
    alert("截止日期不能小于起始日期");
    return false;;
    }
    if(node =="" || null == node){
    alert("请输入节点号");
    return false;;
    }
    if(phase =="" || null == phase){
    alert("请输入相位");
    return false;;
    }
    }
    </script>
    <body bgcolor="#F0F0F0">
    <fieldset>
    <fieldset>
    <legend>查询条件</legend>
    <div align="center">
    <form action="queryInfo.do" method="post" id = "form1" onsubmit="return checkInput()">
    <table class="select">
    <tr>
    <td>
    <table>
    <tr>
    <td>查询日期从&nbsp;&nbsp;<input id="d11" name="startDate" type="text" /></td>
    <td>&nbsp;&nbsp;节点&nbsp;&nbsp;<select name="node" id="d12">
    <option value="Node1">  节点1  </option>
    <option value="Node2">  节点2  </option>
    <option value="Node3">  节点3  </option>
    <option value="Node4">  节点4  </option>
    </select>
    </td>
    </tr>
    <tr>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;到&nbsp;&nbsp;<input id="d13" name="endDate" type="text" onclick="WdatePicker()"/></td>
    <td>&nbsp;&nbsp;相位&nbsp;&nbsp;<select name="phase" id="d14">
    <option value="1">  A相位  </option>
    <option value="2">  B相位  </option>
    <option value="3">  C相位  </option>
    </select></td>
    </tr>
    </table>
    </td>
    <td align="right">
    <input type="submit" class="query" name = "submit" value="查询" />
    </td>
    </tr>
    </table>
    </form>
    </div>
    </fieldset>
    <br/>
    <fieldset>
    <legend>查询结果</legend>
    <div align="center">
    <table>
    <tr>
    <td>
    <input class="textArea" type="textArea" name="resultSet"/>
    </td>
    </tr>
    </table>
    </div>
    </fieldset>
    </fieldset>
    </body>
    </html>
      

  5.   

    可是当起始日期大于截止日期的时候,仍没有进行判断呀!仍然显示的是true。求指教
      

  6.   

    不懂要查资料,不要想当然http://blog.csdn.net/taozi165/article/details/6543863
    http://so.csdn.net/search?q=%E6%97%A5%E6%9C%9F%E6%AF%94%E8%BE%83%E5%A4%A7%E5%B0%8F%20%20javascript
      

  7.   


    if(startDate > endDate){
      alert("截止日期不能小于起始日期");
      return;
    }判断条件写错了……
      

  8.   

    if(startDate > endDate){
      alert("截止日期不能小于起始日期");
      return;
    }