Hi everyone,
I tried and tried, and search Google for two days, still doesnt work, Can you help me finding out why it doesnt work anywhere other than IE?
Thanks
I tried and tried, and search Google for two days, still doesnt work, Can you help me finding out why it doesnt work anywhere other than IE?
Thanks
Code:
<script type='text/javascript'>
//
function isEmpty(elem, helperMsg) {
if (elem.value.length === 0) {
alert(helperMsg);
elem.focus(); // set the focus to this input
return true;
}
return false;
}
function isNumeric(elem, helperMsg) {
var numericExpression = /^[0-9]+$/;
if (elem.value.match(numericExpression)) {
return true;
} else {
alert(helperMsg);
elem.focus();
return false;
}
}
function isAlphabet(elem, helperMsg) {
var alphaExp = /^[a-zA-Z]+$/;
if (elem.value.match(alphaExp)) {
return true;
} else {
alert(helperMsg);
elem.focus();
return false;
}
}
function isAlphanumeric(elem, helperMsg) {
var alphaExp = /^[0-9a-zA-Z]+$/;
if (elem.value.match(alphaExp)) {
return true;
} else {
alert(helperMsg);
elem.focus();
return false;
}
}
function lengthRestriction(elem, min, max) {
var uInput = elem.value;
if (uInput.length >= min && uInput.length <= max) {
return true;
} else {
alert("Please enter between " + min + " and " + max + " characters");
elem.focus();
return false;
}
}
function madeSelection(elem, helperMsg) {
if (elem.value === "Please Choose") {
alert(helperMsg);
elem.focus();
return false;
} else {
return true;
}
}
function emailValidator(elem, helperMsg) {
var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if (elem.value.match(emailExp)) {
return true;
} else {
alert(helperMsg);
elem.focus();
return false;
}
}
//
function formValidator() {
// Make quick references to our fields
var firstname = document.getElementById('firstname');
var secondname = document.getElementById('secondname');
var contactemail = document.getElementById('contactemail');
var telnumber = document.getElementById('telnumber');
var adultnumber = document.getElementById('adultnumber');
var childnumber = document.getElementById('childnumber');
var area = document.getElementById('area');
var dep_day = document.getElementById('dep_day');
var dep_month = document.getElementById('dep_month');
var dep_year = document.getElementById('dep_year');
var ret_day = document.getElementById('ret_day');
var ret_month = document.getElementById('ret_month');
var ret_year = document.getElementById('ret_year');
// Check each input in the order that it appears in the form!
if (isAlphabet(firstname, "Please enter only letters for your first name")) {
if (isAlphabet(secondname, "Please enter only letters for your second name")) {
if (emailValidator(contactemail, "Please enter a valid email address")) {
if (isNumeric(telnumber, "Please enter numbers only for the phone number")) {
if (madeSelection(adultnumber, "Please Choose the number of adults")) {
if (madeSelection(childnumber, "Please Choose the number of children")) {
if (madeSelection(area, "Please Choose Area of Interest")) {
if (madeSelection(dep_day, "Please Choose the departure day")) {
if (madeSelection(dep_month, "Please Choose the departure month")) {
if (madeSelection(dep_year, "Please Choose the departure year")) {
if (madeSelection(ret_day, "Please Choose the return day")) {
if (madeSelection(ret_month, "Please Choose the return month")) {
if (madeSelection(ret_year, "Please Choose return year")) {
return true;
}
}
}
}
}
}
}
}
}
}
}
}
}
return false;
}
</script>
</head>
<body>
<form name="dest" method="POST" action="contactsend.php" onsubmit="return formValidator('dest');">