Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-01-2007, 08:36 PM   PM User | #1
simplemedia00
New to the CF scene

 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
simplemedia00 is an unknown quantity at this point
Login Function/Form submission script...works in Safari/Firefox but not in IE

Hello,

Hopefully someone can help me out with this.

I've created a failry complicated PHP login and survey page for a wedding rsvp. It functions the way I want it to in Safari and in Firefox. But the very first part is not functioning in internet explorer.

Its a simple Firstname / Lastname / Phone Number (password) form. There are the three feilds plus a submit button. The submit button is linked to a validation function that checks all fields are filled then is to submit the form.

Code:
<script type="text/javascript">

function validateRSVP()
{
	valid = true;
	form = document.rsvpform;
		if (form.firstname.value == "")
		{
			valid = false;
		}
			
		if (form.lastname.value == "")
		{
			valid = false;
		}
		if (form.phone.value == "")
		{
			valid = false;
		}
		
		
	if (valid == false) 
	{
		alert("Please enter your information in all required fields");
	}
	
	if (valid == true)
	{
		document.rsvpform.submit();
		
	}
}
</script>
The HTML is as follows:


<form name="rsvpform" id="rsvpform" action="home.php?where=8" method="post">
<table width="400" border="00" align="center">
<tr>
<td colspan="2" align="center"><br><br>Please enter your information to begin the RSVP process<br><br></td>
</tr>
<tr>
<td width="144" align="right"><span id="firstnamediv" class="style1">First Name</td>
<td width="246"><input type="text" maxlength="25" name="firstname" id="firstname" value=""></span></td>
</tr>
<tr>
<td align="right"><span id="lastnamediv">Last Name</td>
<td><input type="text" maxlength="25" name="lastname" id="lastname" value=""></span></td>
</tr>
<tr>
<td align="right"><span id="phonenumberdiv">Phone Number with Area Code</td>
<td><input type="text" maxlength="25" name="phone" id="phone" value=""></span></td>
</tr>
<tr>
<td align="right" ><input type="reset" name="reset" value="Reset"></td>
<td align="left" valign="middle"><input type="button" name="submitform" value="Submit" onClick="validateRSVP();"></td>
</tr>
<tr>
<td colspan="2" align="center"><span class="style1red">The System is currently Down! If you are using anything other than Microsoft Internet Explorer, you should not have any problems. We are trying to fix it as fast as possible!. If you have any problems please email at mike@simplemediaindustries.com</span></td>
</tr>
<input type="hidden" id="rsvp" name="rsvp" value="true">
</form>
</table>

Like I said seems to work fine in Safari / Firefox , but not IE....Any ideas?

I've even replaced the function with a simple alert and the form button does not respond in IE.

You can see the raw page at www.mikeandsarahgetmarried.com/rsvp.php

or you can see it in context at www.mikeandsaragetmarried.com/home.php?where=8

I appreciate any help (and so does my fiance!!!!)

Mike
simplemedia00 is offline   Reply With Quote
Old 05-01-2007, 08:54 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,036
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
<td align="left" valign="middle"><input type="button" name="submitform" value="Submit" onClick="validateRSVP();" ></td>

Delete the part in red.

<form name="rsvpform" id="rsvpform" action="home.php?where=8" method="post" onSubmit = "return validateRSVP(this.submitform)">

Add the part in blue.

Revise this part:-

if (valid == false) {
alert("Please enter your information in all required fields");
return false;
}
else {return true}

That should fix it!


I would try to improve the validation by making it require a minimum length of a field to be valid by e.g.

if (form.firstname.value.length < 3) // or whatever

as otherwise even a single space in the text box will return true. Further improvement would accept only letters (and - ') in the names fields and only numbers in the phone field.

Last edited by Philip M; 05-01-2007 at 09:06 PM..
Philip M is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 09:25 PM.


Advertisement
Log in to turn off these ads.