Digital Point Forums
Money Transfer

Go Back   Digital Point Forums > Design & Development > Programming > JavaScript
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old May 5th 2005, 7:57 am
T0PS3O's Avatar
T0PS3O T0PS3O is offline
Feel Good PLC
 
Join Date: Mar 2004
Location: 0101010101001011
Posts: 13,221
T0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond repute
Question Form Validation Won't Work In FF

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?

Code:
<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:

Code:
<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!
__________________
Try:
Sell Your Ad Space - Thousands Of Visitors Want To Buy Your Ad Space
Global Internet Index Directory <- Check it out! ->
Reply With Quote
  #2  
Old May 5th 2005, 8:46 am
T0PS3O's Avatar
T0PS3O T0PS3O is offline
Feel Good PLC
 
Join Date: Mar 2004
Location: 0101010101001011
Posts: 13,221
T0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond repute
My web developer toolbar says "Error: document.all has no properties". Google searches seem to suggest innerHTML is not part of the DOM (whatever that may mean) so FF doesn't support it. Can this be true? Ideally I'd rewrite the whole validation to server side but I'll have to give fixing this a try first...

This is the line.

Code:
document.all['Val'].innerHTML = "Required fields: " + Result.substr(1);
__________________
Try:
Sell Your Ad Space - Thousands Of Visitors Want To Buy Your Ad Space
Global Internet Index Directory <- Check it out! ->
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS, HTML, FIELDSET, LEGEND, and LABEL tags in FORM itgl72 CSS 2 Jul 19th 2005 2:15 pm
php form entry from list Pep PHP 3 Feb 20th 2005 6:29 am
Retain email form (with errors) after submit ian_ok PHP 5 Feb 12th 2005 1:33 pm
Leads with form on 'my' page? Sanzbar Affiliate Programs 3 Jan 28th 2005 11:21 am
javascript form validation help NewComputer JavaScript 1 Oct 9th 2004 1:53 am


All times are GMT -8. The time now is 12:02 pm.