我有以下代码和验证来检查输入的日期是否有效。我需要添加一些简单的 javascript 验证来检查“到期”日期是否早于“审阅”日期。如果到期日期是审查日期之前的日期,则可以,如果没有,则给出错误警报框。谢谢你的帮助。
我想我可以比较这两个字符串,看看一个是 < 还是另一个,但不确定最好的方法是什么。
<tr>
<td class="SubHeader" height="5%">Review</td>
</tr>
<tr>
<td class="Label">Review By</td>
<td>
<input class="amdInputText" type="text" id="guaranteereviewbydate" value="">
<xsl:attribute name="value"><xsl:value-of select="guaranteereviewbydate"/></xsl:attribute>
</input>
</td>
</tr>
<tr>
<td class="Label">Expire On</td>
<td><input class="amdInputText" type="text" id="guaranteeexpireondate" value="">
<xsl:attribute name="value"><xsl:value-of select="guaranteeexpireondate"/></xsl:attribute>
</input>
</td>
</tr>
<xsl:if test="count(../bankguaranteedata) > '1'">
else if(!validateDate(document.lending.guaranteereviewbydate[<xsl:value-of select="@id"/>].value)){alert("Please enter a valid review by date. The date must be of the format dd/mm/yyyy");document.lending.guaranteereviewbydate[<xsl:value-of select="@id"/>].focus();return false;}
else if(!validateDateExpireOn(document.lending.guaranteeexpireondate[<xsl:value-of select="@id"/>].value)){alert("Please enter a valid expire on date. The date must be of the format dd/mm/yyyy");document.lending.guaranteeexpireondate[<xsl:value-of select="@id"/>].focus();return false;}
</xsl:if>
<xsl:if test="count(../bankguaranteedata) = '1'">
else if(!validateDate(document.lending.guaranteereviewbydate.value)){alert("Please enter a valid review by date. The date must be of the format dd/mm/yyyy");document.lending.guaranteereviewbydate.focus();return false;}
else if(!validateDateExpireOn(document.lending.guaranteeexpireondate.value)){alert("Please enter a valid expire on date. The date must be of the format dd/mm/yyyy");document.lending.guaranteeexpireondate.focus();return false;}
</xsl:if>