T0PS3O
May 5th 2005, 7:57 am
Can someone please have a look at this code for me please? This works just fine in IE but not in FF. Can someone guide me in the right direction re: which part is the culprit please?
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function CheckForm() {
var Result;
Result = "";
//Result = Result + chkemail(document.theForm.Email.value, ", Email");
//Result = Result + checkDropDown("Property", ", Property");
Result = Result + chkLength(document.theForm.ContactName.value, ", Contact Name");
Result = Result + chkLength(document.theForm.CompanyName.value, ", Company Name");
Result = Result + chkemail(document.theForm.EmailAddress.value, ", Email Address");
Result = Result + chkLength(document.theForm.Password.value, ", Password");
Result = Result + chkLength(document.theForm.ConfirmPassword.value, ", Confirm Password");
//Result = Result + chkLength(document.theForm.YourName.value, ", Your Name");
//Result = Result + chkLength(document.theForm.ContactsSurname.value, ", Surname");
//Result = Result + checkDropDown("Sector", ", Sector");
//Result = Result + checkDropDown("country", ", Country");
if (Result.length > 0) {
document.all['Val'].innerHTML = "Complete the fields: " + Result.substr(1);
return false;
}
else
{
return true;
}
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function chkLength(str, response)
{
strReturn = "";
if (str.length < 1) {
strReturn = response;
}
return (strReturn);
}
function checkDropDown(dropDownName, response)
{
strReturn = "";
if (document.theForm[dropDownName].selectedIndex == 0) {
strReturn = response;
}
return (strReturn);
}
function chkemail(str, response) {
strReturn = "";
if (str.length > 0) {
i = str.indexOf("@");
j = str.indexOf(".",i);
k = str.indexOf(",");
kk = str.indexOf(" ");
jj = str.lastIndexOf(".")+1;
len = str.length;
if (!((i > 0) && ( j > (i + 1)) && (k == -1) && (kk == -1) && (len - jj >= 2) && (len - jj <= 3))) {
strReturn = response;
} else {
if (str.length < 1) {
strReturn = response;
}
}
} else {
strReturn = response;
}
return (strReturn);
}
//-->
</SCRIPT>
Form element example:
<form action="new_go.asp" method="post" name="theForm" onSubmit="Javascript:return(CheckForm());" ID="Form2"><input class=x id=Text1 type=text size=60 name=EmailAddress>
<input class=Button id="Submit2" type=submit value=Submit name=Submit1></form>
Validation works great in IE, not in FF (redirects to homepage, strange!).
Thank you!
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function CheckForm() {
var Result;
Result = "";
//Result = Result + chkemail(document.theForm.Email.value, ", Email");
//Result = Result + checkDropDown("Property", ", Property");
Result = Result + chkLength(document.theForm.ContactName.value, ", Contact Name");
Result = Result + chkLength(document.theForm.CompanyName.value, ", Company Name");
Result = Result + chkemail(document.theForm.EmailAddress.value, ", Email Address");
Result = Result + chkLength(document.theForm.Password.value, ", Password");
Result = Result + chkLength(document.theForm.ConfirmPassword.value, ", Confirm Password");
//Result = Result + chkLength(document.theForm.YourName.value, ", Your Name");
//Result = Result + chkLength(document.theForm.ContactsSurname.value, ", Surname");
//Result = Result + checkDropDown("Sector", ", Sector");
//Result = Result + checkDropDown("country", ", Country");
if (Result.length > 0) {
document.all['Val'].innerHTML = "Complete the fields: " + Result.substr(1);
return false;
}
else
{
return true;
}
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function chkLength(str, response)
{
strReturn = "";
if (str.length < 1) {
strReturn = response;
}
return (strReturn);
}
function checkDropDown(dropDownName, response)
{
strReturn = "";
if (document.theForm[dropDownName].selectedIndex == 0) {
strReturn = response;
}
return (strReturn);
}
function chkemail(str, response) {
strReturn = "";
if (str.length > 0) {
i = str.indexOf("@");
j = str.indexOf(".",i);
k = str.indexOf(",");
kk = str.indexOf(" ");
jj = str.lastIndexOf(".")+1;
len = str.length;
if (!((i > 0) && ( j > (i + 1)) && (k == -1) && (kk == -1) && (len - jj >= 2) && (len - jj <= 3))) {
strReturn = response;
} else {
if (str.length < 1) {
strReturn = response;
}
}
} else {
strReturn = response;
}
return (strReturn);
}
//-->
</SCRIPT>
Form element example:
<form action="new_go.asp" method="post" name="theForm" onSubmit="Javascript:return(CheckForm());" ID="Form2"><input class=x id=Text1 type=text size=60 name=EmailAddress>
<input class=Button id="Submit2" type=submit value=Submit name=Submit1></form>
Validation works great in IE, not in FF (redirects to homepage, strange!).
Thank you!