...

View Full Version : Login Function/Form submission script...works in Safari/Firefox but not in IE



simplemedia00
05-01-2007, 09:36 PM
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.


<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

Philip M
05-01-2007, 09:54 PM
<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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum