0

Instead of using a button to submit my forms i using the following markup

<a id="logmein" class="my_button">LOGIN</a> 

Which sits either just outside the form or sometimes inside the form and the following jquery

$("#logmein").click(function(e) {
    e.preventDefault();
    $("#login").submit();
    return false;
});

I have been wondering why this wont work in IE. After some investigating i have discovered that to cut a long story short it wont work in IE, but actaully finding a SIMPLE solution is prooving a lot harder. I have just under 93 million billion forms on my site and I dont fancy re-writing testing them all with some annoying MS friendly code to do something like this

jquery's form submit not working in IE

Is there are more elegant simplier way to get these dam forms to submit .... or shall i just re-direct all ie users to a big 300 spartans hole on the internet

thanks for listening....

Community
  • 1
  • 1
AttikAttak
  • 797
  • 4
  • 12
  • 20
  • 1
    You need to append the form to the DOM before submitting. Here's some help: http://stackoverflow.com/questions/3770324/jquerys-form-submit-not-working-in-ie – Niklas Dec 11 '12 at 11:07
  • 2
    Maybe a stupid suggestion, but did you try the old-school `document.forms["login"].submit();`? – David Hellsing Dec 11 '12 at 11:09
  • 1
    You should set a href attribute to your 'A' tag like 'href="#"' and remove 'return false;' of your click callback function. BTW, is your form 'login' in DOM? – A. Wolff Dec 11 '12 at 11:10
  • what part doesn't work? nothing shown should be a problem in IE if form exists in DOM and button exists when you call your code – charlietfl Dec 11 '12 at 11:13
  • your code seems to work in ie7: http://jsfiddle.net/7cg3E/1/ – Jai Dec 11 '12 at 11:14
  • Hi there my version is ie9 and i do have the href="" in hte a-tag... sorry about that copy an dpaste error above... when i press the login button... the form does nothing... no submit and not default action. if i put an alter inside the jquery that works fine too just not the submit bit... will go through the other suggestion now... thanks – AttikAttak Dec 11 '12 at 12:17
  • Ok i put this in the jquery.. if ($('#login').length > 0) { alert("hi"); } and that succesfully altered hi, so it is in the dom, i removed the return false... and still nothing happened.... :( – AttikAttak Dec 11 '12 at 12:27
  • so this one works!!! the old-school way - document.forms["login"].submit(); so unless anyone else has any ideas its going to be alot more simplier to add an old fashioned 1998 onclick event to all my fake buttons that to get ie9 to work with a simple jquery .. grrr @ ie and thumbs up to david ... thanks everyone – AttikAttak Dec 11 '12 at 12:37

0 Answers0