﻿
function ClearText()
{
   $("#txtCompany").val("");
    $("#txtContactPerson").val("");
    $("#txtTitle").val("");
    $("#txtPhone").val("");    
    $("#txtFax").val("");
    $("#txtEmail").val("");
    $("#txtAddress").val("");    
    $("#txtPersonConnt").val("");
    $("#txtTotalMoney_p").val("");
    $("#txtTableCount").val("");    
    $("#txtTotalMoney_t").val("");
    $("#txtChequeNo").val("");
    $("#txtPersonName1").val("");
    $("#txtPersonName2").val("");
    $("#txtPersonName3").val("");
    $("#txtPersonName4").val("");
    $("#txtPersonName5").val("");
    $("#txtPersonName6").val("");
    $("#txtPersonName7").val("");
    $("#txtPersonName8").val("");
    $("#txtPersonName9").val("");
    $("#txtPersonName10").val("");
    $("#txtPersonName11").val("");
    $("#txtPersonName12").val("");
    $("#txtPersonName13").val("");
    $("#txtPersonName14").val("");
    $("#txtPersonName15").val("");
    $("#txtPersonName16").val("");
    $("#txtPersonName17").val("");
    $("#txtPersonName18").val("");
    $("#txtPersonName19").val("");
    $("#txtPersonName20").val("");
    $("#txtPersonName21").val("");
    $("#txtPersonName22").val("");
    $("#txtPersonName23").val("");
    $("#txtPersonName24").val("");
    $("#txtPersonName25").val("");
    $("#txtPersonName26").val("");
    $("#txtPersonName27").val("");
    $("#txtPersonName28").val("");
    $("#txtPersonName29").val("");
    $("#txtPersonName30").val("");    
    $("#txtCompany").focus();
}

function checkemail( parm )
{ 
    // 正则表达式对象
    var re = new RegExp("\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*", "");
     if(  re.test( parm.toString() ) )
     {
     return true;
     }
     return false;
}

function checknumber(parm)
{
    // 正则表达式对象
    var re = new RegExp("\\d+$", "");
    if(re.test( parm.toString() )  )
    {
    return true;
    }
    return false;
}
function checkForm()
{
    var txtCompany = document.getElementById("txtCompany");
    if(txtCompany.value =="")
     {
        alert('Please input your Company');
        txtCompany.focus();
        return false;
     }
     
    var txtContactPerson = document.getElementById("txtContactPerson");
    if(txtContactPerson.value =="")
     {
        alert('Please input your Contact Person 聯絡人');
        txtContactPerson.focus();
        return false;
     }
     
    var txtTitle = document.getElementById("txtTitle");
    if(txtTitle.value =="")
     {
        alert('Please input your Title 職位');
        txtTitle.focus();
        return false;
     }
      var txtPhone = document.getElementById("txtPhone");
    if(txtPhone.value =="")
     {
        alert('Please input your Phone 電話');
        txtPhone.focus();
        return false;
     }
     if(!checknumber(txtPhone.value))
     {
        alert('Please input an available Tel number');
        txtPhone.focus();
        return false;
     }  

      var txtEmail = document.getElementById("txtEmail");
    if(txtEmail.value =="")
     {
        alert('Please input your E-mail 電郵');
        txtEmail.focus();
        return false;
     }
     if(!checkemail(txtEmail.value))
     {
        alert('Please input an available E-mail Address');
        txtEmail.focus();
        return false;
     }

      var txtAddress = document.getElementById("txtAddress");
    if(txtAddress.value =="")
     {
        alert('Please input your  Address 地址');
        txtAddress.focus();
        return false;
     }
      var txtPersonConnt = document.getElementById("txtPersonConnt");
    if(txtPersonConnt.value =="")
     {
        alert('Please input your Person(位)');
        txtPersonConnt.focus();
        return false;
     }
      //var txtTableCount = document.getElementById("txtTableCount");
    //if(txtTableCount.value =="")
     //{
        //alert('Please input your Table(s)台');
        //txtTableCount.focus();
        //return false;
     //}
    //var txtChequeNo = document.getElementById("txtChequeNo");//注释掉 支票的验证
    //if(txtChequeNo.value =="")
     //{
        //alert('Please input your Enclosed Cheque No.現附上銀行支票號碼');
        //txtChequeNo.focus();
       // return false;
     //}
      return true;
}
