I have the following logic to verify fields contain data before they are submitted:
This works fine in IE and Safari but in FF it keeps saying my fields need to contain data even though they already do.
Any ideas? Thanks.
Swi
Code:
function trimAll(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}
function newRecord()
{
if (trimAll(document.dgridFrm.elements[1].value) == "")
{
alert("Please enter a logon id!")
document.dgridFrm.elements[1].focus();
}//end if
else if (trimAll(document.dgridFrm.elements[2].value) == "")
{
alert("Please enter a password!")
document.dgridFrm.elements[2].focus();
}//end if
else if (trimAll(document.dgridFrm.elements[3].value) == "")
{
alert("Please enter a full name!")
document.dgridFrm.elements[3].focus();
}//end if
else if (trimAll(document.dgridFrm.elements[6].value) != "0" && trimAll(document.dgridFrm.elements[6].value) != "1")
{
alert("Please enter a 1 (yes) or 0 (no) for active!")
document.dgridFrm.elements[6].focus();
}//end if
else if (trimAll(document.dgridFrm.elements[7].value) != "0" && trimAll(document.dgridFrm.elements[7].value) != "1")
{
alert("Please enter a 1 (yes) or 0 (no) for admin!")
document.dgridFrm.elements[7].focus();
}//end if
else
{
var d1=new Date();
document.dgridFrm.elements[4].value = d1.getMonth()+1 + '/' + d1.getDate() + '/' + d1.getFullYear();
document.dgridFrm.action = "save.asp";
document.dgridFrm.submit();
}//end else
}//end of newRecord()
This works fine in IE and Safari but in FF it keeps saying my fields need to contain data even though they already do.
Any ideas? Thanks.
Swi