|
function checkForm() {
if (trim(document.forms[0].Foretag.value) == "") {
alert("You have to provide us with your company name.");
return false;
}
if (trim(document.forms[0].Fornamn.value) == "") {
alert("You have to provide us with your first name.");
return false;
}
if (trim(document.forms[0].Efternamn.value) == "") {
alert("You have to provide us with your last name.");
return false;
}
if (trim(document.forms[0].Gatuadress.value) == "") {
alert("You have to provide us with your address.");
return false;
}
if (trim(document.forms[0].Postnummer.value) == "") {
alert("You have to provide us with your zip code.");
return false;
}
if (trim(document.forms[0].Postort.value) == "") {
alert("You have to provide us with your city.");
return false;
}
if (trim(document.forms[0].Telefon.value) == "") {
alert("You have to provide us with your phone number.");
return false;
}
if (trim(document.forms[0].Meddelande.value) == "") {
alert("You have to add a message.");
return false;
}
if (trim(document.forms[0].Epost.value) == "") {
alert("You have to provide us with your E-mail address.");
return false;
}
var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
var check=/@[\w\-]+\./;
var checkend=/\.[a-zA-Z]{2,3}$/;
if (((document.forms[0].Epost.value.search(exclude)!= -1) ||
(document.forms[0].Epost.value.search(check))== -1) ||
(document.forms[0].Epost.value.search(checkend)== -1)) {
alert("Wrong E-mail format!");
return false;
}
document.forms[0].isValidated.value = "true";
document.forms[0].submit();
return true;
}
function trim(frmObj) {
var data = "";
for(var i = 0 ; i < frmObj.length ; i++) {
if (frmObj.substring(i,i+1) != ' ') {
data = data + frmObj.substring(i,i+1)
}
}
return data
}
| . | |
|