Hi,
In the following code, how would I go about validating select menus and checkboxes. I'm aware this not a method using DOM, I'm new to JS and going old skool at the moment
In the following code, how would I go about validating select menus and checkboxes. I'm aware this not a method using DOM, I'm new to JS and going old skool at the moment
Code:
//start JS
<!--
//Check for email address: look for [@] and [.]
function isEmail(elm){
if(elm.value.indexOf("@")+"" != "-1" &&
elm.value.indexOf(".") + "" != "-1" &&
elm.value != "")
return true;
else return false;
}
//Check for null and for empty
function ifFilled(elm){
if(elm.value==""||
elm.value == null)
return false;
else return true;
}
function isReady(form){
//is address a real email address?
if(isEmail(form.email)==false){
alert("Please enter your email address.");
form.email.focus();
return false;
}
//is FirstName element filled?
if(isFilled.form.firstName==false){
alert("Please enter your First Name.");
form.firstName.focus();
return false;
}
//is LastName element filled?
if(isFilled.form.lastName==false){
alert("Please enter your Last Name.");
form.lastName.focus();
return false;
}
//is comments filled?
if(isFilled.form.comments==false){
alert("Please, speak your mind.");
form.comments.focus();
return false;
}
return true;
}
//-->