﻿// JScript File
function getCompanyName() {
var cName = document.getElementById("cName").value;
if (cName.length == 0) {
document.getElementById("cName").focus();
return 0
}
return cName
}

function getContactName() {
var contact = document.getElementById("contact").value;
if (contact.length == 0) {
document.getElementById("contact").focus();
return 0
}
return contact
}

function getTEL() {
var tel = document.getElementById("TEL").value;
if (tel.length == 0) {
document.getElementById("TEL").focus();
return 0
}
return tel
}

function getFAX() {
var fax = document.getElementById("FAX").value;
return fax
}

function getADDR() {
var addr = document.getElementById("ADDR").value;
return addr
}

function getMAIL() {
var mail = document.getElementById("eMAIL").value;
if (mail.length == 0) {
document.getElementById("eMAIL").focus();
return 0
}
if (mail == 'gary@gary.com.tw') {
return -2
}
if ((mail.indexOf("@") == -1) || mail.indexOf(".") == -1) {
document.getElementById("eMAIL").focus();
return -1
}
return mail
}

function getMSG() {
var msg = document.getElementById("MSG").value;
return msg
}

function getSEX() {
var male = document.getElementById("male");
var female = document.getElementById("female");
if (male.checked == true) {
return 1
}
if (male.checked == false && female.checked == false) {
return -1
}
return 0
}

function check() {
var ret = true
if (getCompanyName() == 0) {
ret = false;
alert("Company Name can't be empty !");
return ret
}

if (getContactName() == 0) {
ret = false;
alert("Contact Person can't be empty !");
return ret
}

if (getTEL() == 0) {
ret = false;
alert("Telphone can't be empty !");
return ret
}

if (getMAIL() == 0) {
ret = false;
alert("E-Mail can't be empty !");
return ret
}

if (getMAIL() == -2) {
ret = false;
alert("Access Deny !");
return ret
}

if (getMAIL() == -1) {
ret = false;
alert("E-Mail format is wrong !");
return ret
}
return ret
}


