treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Html5 problem IE9

  • Hi, currently I've a strange problem I don't understand.

    I've created a HTML5 Form and for IE I've included a placeholder shim. The Form has two buttons one for submit and another one for downloading a PDF.

    I've created a small JQuery script which basically validates a few form fields if everything is alright it submits everything to process.php and then resets the form fields to their initial values...

    The problem starts with IE while trying to reset the form fields it does not work. But if you fill out all required fields and hit the download button magically the form fields resetting! That drives me nuts because that seems to be kind of a default behavior?

    I wonder how I could write a function which works in all browsers to reset the form fields to their placeholder text...

      function resetform() {
      formid.find("input").each(function () {
        jQuery(this).val(""); 
      })
      formid.find("textarea").val("");
      emailsend = false;
    } 
    

    Strange in all other Browsers this works fine.

    kindest regards, Marc

  • Why not just use the standard reset method that all browsers have built into them?

    function resetform() {
        formid.get(0).reset();
        emailsend = false;
    }
    
  • Hi, good question I dont remember:) But your code works perfectly thank you very much for this...

    There is just s small issue left in IE after the reset all fields are totally blank while other browsers showing the placeholder text instead. When I click in one of those totally blank fields in IE the placeholder text is shown again... Thats kinda ugly to me is there a way to solve this too?

    regards Marc

  • There is just s small issue left in IE after the reset all fields are totally blank while other browsers showing the placeholder text instead. When I click in one of those totally blank fields in IE the placeholder text is shown again

    You could maybe use something really ugly like the following which should work.

    function resetform() {
        formid.get(0).reset();
        emailsend = false;
    
        $('input, textarea', formid).each(function() {
            this.focus();
        });
    
        $('input:first', formid).get(0).focus();
    }
    
  • [ironie on]IE rulez[ironie off] You're right it really works even if its ugly...

    Thank you

  • [ironie on]IE rulez[ironie off]

    Spellcheck off too...apparently. :_

  • Yeah sorry this happend if you think german and writen english :(