
Cross - Browser input field problems
I have created the following script as a generic routine to handle mandatory
fields on an input form. All mandatory fields are suffixed with the
following three letters "_MF". For example, Name_MF, Age_MF, etc. Each form
calls the following method to check whether or not the user has filled in
these fields.
function checkForBlanks()
{
var nElements
var strObjectName
var strObjectVal
var nMissingFields
file://store the number of elements on form to variable nElements
nElements = document.forms[0].length;
nMissingFields=0
// loop through each element in the form
for (x=0; x<nElements; x++)
{
// store relevant values into variables
strObjectName = document.forms[0].elements[x].name
strObjectVal=document.forms[0].elements[x].value
alert(strObjectName)
alert(strObjectVal)
// test for blank mandatory field.
if
((strObjectName.substring(strObjectName.length-3,strObjectName.length)=="_MF
") && ((strObjectVal=="") || (strObjectVal==null)))
{
alert("Some of the mandatory input boxes (Denoted by an asterisk) are
blank. Please complete them before continuing.");
return (false);
}
}
return (true);
Quote:
}
The script works wonderfully well in IE4 but I am experiencing problems ins
Opera and Netscape Navigator.
Does anybody know why Opera returns "null" for every element in the form,
whilst Netscape sees all the values except for those in a select drop down
list and Internet Explorer has no problem what-so-ever?
Thanks Mark
--
http://www.*-*-*.com/