﻿// JScript 文件
//检查是否为整数
function isInteger(s) {
    if (s != null) {
        var r, re;
        re = /\d*/i; //\d表示数字,*表示匹配多个数字
        r = s.match(re);
        return (r == s) ? true : false;
    }
    return false;
}
//检查是否为数字
function isNumeric(s) {
    if (s != null && s != "") {
        return !isNaN(s);
    }
    return false;
}

function isValidURL(chars) {
    //var re="/^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)((((\w+(-*\w*)+)\.)+((com)|(net)|(edu)|(gov)|(org)|(biz)|(aero)|(coop)|(info)|(name)|(pro)|(museum))(\.([a-z]{2}))?)|((\w+(-*\w*)+)\.(cn)))$/";
    //var re=/^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(\S+\.\S+)$/;
    //var re=/^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(((((\w+(-*\w*)+)\.)+((com)|(net)|(edu)|(gov)|(org)|(biz)|(aero)|(coop)|(info)|(name)|(pro)|(ws)|(us)|(uk)|(museum)|(cn)|(tv)|(hk))(\.([a-z]{2}))?)|((\w+(-*\w*)+)\.(cn)))((\/|\?)\S*)*)$/;
    // 其它几种写法:
    var re = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)((\w+)\.)+(\S)+$/;
    //var re=/^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/;
    //var re=/^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)((\w+)\.)+(\S)+$/;
    //chars = jsTrim(chars);

    if (chars.match(re) == null)
        return false;
    else
        return true;

}


function CheckOrderInfo(sortID, name,tel,startDate,endDate,roomName,amount) {
    if (sortID.value == "-1") {
        alert("请选择栏目！");
        sortID.focus();
        return false;
    }

    if (trim(name.value) == "") {
        alert("客户名称不能为空！");
        name.focus();
        return false;
    }

    if (trim(tel.value) == "") {
        alert("联系电话不能为空！");
        tel.focus();
        return false;
    }

    if (trim(startDate.value) != "") {
        if (isDate(startDate.value) == false) {
            return false;
        }
    }
    else {
        alert("入住日期不能为空！");
        startDate.focus();
        return false;
    }

    if (trim(endDate.value) != "") {
        if (isDate(endDate.value) == false) {
            return false;
        }
    }
    else {
        alert("离店日期不能为空！");
        endDate.focus();
        return false;
    }


    if (trim(roomName.value) == "") {
        alert("请输入房间类型！");
        roomName.focus();
        return false;
    }

    if (trim(amount.value) == "") {
        alert("预订房间数量不能为空！");
        amount.focus();
        return false;
    }
    else {
        if (isInteger(amount.value) == false) {
            alert("预订房间数量输入错误！");
            amount.focus();
            amount.select();
            return false;
        }
    }

    return true;
}

function CheckOrderInfo2(name, tel, startDate, endDate, roomType, amount) {

    if (trim(name.value) == "") {
        alert("客户名称不能为空！");
        name.focus();
        return false;
    }

    if (trim(tel.value) == "") {
        alert("联系电话不能为空！");
        tel.focus();
        return false;
    }

    if (trim(startDate.value) != "") {
        if (isDate(startDate.value) == false) {
            return false;
        }
    }
    else
    {
        alert("入住日期不能为空！");
        startDate.focus();
        return false;
    }

    if (trim(endDate.value) != "") {
        if (isDate(endDate.value) == false) {
            return false;
        }
    }
    else {
        alert("离店日期不能为空！");
        endDate.focus();
        return false;
    }

    if (roomType.value == "0") {
        alert("请选择房型！");
        roomType.focus();
        return false;
    }

    if (trim(amount.value) == "") {
        alert("预订房间数量不能为空！");
        amount.focus();
        return false;
    }
    else {
        if (isInteger(amount.value) == false) {
            alert("预订房间数量输入错误！");
            amount.focus();
            amount.select();
            return false;
        }
    }

    return true;
}




function CheckOrderInfo3(startDate, endDate, roomType, amount) {

    if (trim(startDate.value) != "") {
        if (isDate(startDate.value) == false) {
            return false;
        }
    }
    else {
        alert("入住日期不能为空！");
        startDate.focus();
        return false;
    }

    if (trim(endDate.value) != "") {
        if (isDate(endDate.value) == false) {
            return false;
        }
    }
    else {
        alert("离店日期不能为空！");
        endDate.focus();
        return false;
    }

    if (roomType.value == "0") {
        alert("请选择房型！");
        roomType.focus();
        return false;
    }

    if (trim(amount.value) == "") {
        alert("预订房间数量不能为空！");
        amount.focus();
        return false;
    }
    else {
        if (isInteger(amount.value) == false) {
            alert("预订房间数量输入错误！");
            amount.focus();
            amount.select();
            return false;
        }
    }

    return true;
}

