miniui 结束日期不能小于起始日期

1.HTML代码:

<tr>
  <th class="nui-form-label" style="width:15%;"><label for="report.startDate$text" >起始日期:</label></th>
  <td style="width:35%;" >
  <input id="report.startDate" class="nui-datepicker" style="width: 95%;" name="report.startDate" required="true"/>
  </td>


  <th class="nui-form-label" style="width:15%;"><label for="report.productCode$text">结束日期:</label></th>
  <td style="width:35%;">
  <input id="report.endDate" class="nui-datepicker" name="report.endDate" style="width: 95%;" required="true" onvaluechanged="onValueChanged"/>
  </td>
</tr>

 

2.JS代码:

function onValueChanged(e){
  var startDate = nui.get("report.startDate").getFormValue();
  var endDate = e.value;
  if(startDate!="")
  startDate=startDate.substring(0,4) + startDate.substring(5,7) + startDate.substring(8,10);
  if(endDate!="")
  endDate=endDate.substring(0,4) + endDate.substring(5,7) + endDate.substring(8,10);
  if(startDate>endDate){
  e.isValid=false;
  nui.alert("不能小于起始日期");
  nui.get("report.endDate").setValue("");
  }
}

你可能感兴趣的:(miniui 结束日期不能小于起始日期)