views:

130

answers:

3

Hi guys, I'm trying to pass an email through a GET form, but in IE, it strips out the @ symbol on the page with the GET parameters. I'm using an onSubmit event, but all those do is validate the data before letting them submit, it doesn't touch any of the form values.

<form name="quick" id="ex" action="order" autocomplete="off" method="GET" onsubmit="return validateQuickForm(this);">
<input id="eMail" value="" name="email" onblur="validateField(this, VALIDATE_EMAIL, false)" type="text">
....
<input src="/images/button.gif" value="Submit" alt="Submit" title="Continue to order form" type="image">
</form>

Let's say I input [email protected]..

It should redirect me to

example.org/order/?email=user%40example.org

But it redirects me to

example.org/order/?email=userexample.org

It works fine in Firefox..

Here's the javascript function, just in case:

function validateQuickForm(form) {
    var errors = new Array();
    if (VALIDATE_EMAIL(form.email) == false) 
     errors.push("That's not a valid email!");
    if (errors.length > 0) {
     var errorMsg = "Please fill out all fields correctly:";
     for(var i = 0; i < errors.length; i++)
      errorMsg += "\r\n-"+errors[i];
     alert(errorMsg);
     return false;
    }
    return true;
}

Also, I've removed the javascript and events and it still strips out the @ regardless

A: 

@ before the hostname in the URL can signify authentication info. I know this support was removed from IE a while back, for security purposes, maybe they overdid it.

See e.g. http://gadgetopia.com/post/2027 and section 3.1 of http://www.ietf.org/rfc/rfc1738.txt.

Have you tried explicitly URL-encoding it before submitting the form?

Kim Gräsman
Small correction; authentication is at the beginning of the hostname (i.e. `http://user:[email protected]/`), not the end.
You
How do I encode it in javascript? I tried escape(form.email.value) it and it still stripped out the @ in the get param. And manually replacing @ with %40 makes %40 display on the next form input it redirects to.
CD Sanchez
@You - thanks, I noticed and edited before I saw your reply. Thanks for the example.
Kim Gräsman
@Daniel - OK, that doesn't seem to do it either, then.
Kim Gräsman
+1  A: 

Something else is causing your problem. If you take out your javascript, the "@" does correctly get sent in the querystring. Does the "VALIDATE_EMAIL" function ever set the value of the INPUT field? My guess is that it is stripping it out in IE.

David
Right now all I have is a dummy function that returns true if it has an @ in the value... until I can find something more suitable.function VALIDATE_EMAIL(element) { return element.value.indexOf("@") != -1;}
CD Sanchez
What does "validateField" do?
David
A: 

Well, I just ended up using POST instead and there aren't any issues with that. IE probably filters out @ for pseudo-security reasons. I'm sure there's a work around to use GET for emails, but the alternative (POST) is much more easier and doesn't require any hacks to get around.

CD Sanchez
It's not an IE security problem. It works just fine with a plain HTML form in IE so something else on your page is doing it.
David