主题:  求救:这样的两个表单对象怎样在客户端被验证

microsoft99

职务:普通成员
等级:1
金币:0.0
发贴:5
注册:2003/11/28 22:59:31
#12003/12/1 21:40:11
我想做一个酒店查询:
其中有两个文本框:1,入住时间 2,离开时间
检验条件是:1,离开时间应该在入住时间之后。
2,入住时间不能晚于当天日期。
请问在DreamweaverMX中该如何去做或该如何写代码。
在这里先谢谢大家了!!!



bihu

职务:普通成员
等级:1
金币:1.0
发贴:227
注册:2001/10/10 7:57:50
#22003/12/6 16:40:16
<script language="javascript">
function compareDate(strDate1,strDate2) {
    var tmp1=strDate1.split('/');
    var tmp2=strDate2.split('/');
    var date1=eval('new Date('+tmp1[2]+','+tmp1[1]+','+tmp1[0]+')');
    var date2=eval('new Date('+tmp2[2]+','+tmp2[1]+','+tmp2[0]+')');
    return (date2.valueOf()-date1.valueOf())>=0;
}
function doSearch()
{
var site = document.reptable.site.value;
var type = document.reptable.type.value;
var fromDate = document.reptable.fromDate.value;
var toDate = document.reptable.toDate.value;
var id = document.reptable.id.value;
var view = document.reptable.view.value;
        if(id.length<1)
             {
            alert("请输入要查询的关键字!");
            return;
             }

        if(fromDate.length<1)
             {
            alert("请输入起始日期!");
            return;
             }

        if(toDate.length<1)
             {
            alert("请输入中止日期!");
            return;
             }
        if (! compareDate(fromDate,toDate)) {
            alert('起始日期不能晚于中止日期!');
            return false;
        }
}