i use markup like
<input type="text" form="myform" name="inp1" /> <form id="myform" name="myform"> ... </form> now realized doesn't work oldie , therefore searching html5 polyfill, didn't found 1 google.
anyone aware of lib or polyfill covers html5 feature?
i wrote polyfill emulate such feature duplicating fields upon form submission, tested in ie6 , works fine.
(function($) { /** * polyfill html5 form attr */ // detect if browser supports var sampleelement = $('[form]').get(0); var isie11 = !(window.activexobject) && "activexobject" in window; if (sampleelement && window.htmlformelement && sampleelement.form instanceof htmlformelement && !isie11) { // browser supports it, no need fix return; } /** * append field form * */ $.fn.appendfield = function(data) { // form if (!this.is('form')) return; // wrap data if (!$.isarray(data) && data.name && data.value) { data = [data]; } var $form = this; // attach new params $.each(data, function(i, item) { $('<input/>') .attr('type', 'hidden') .attr('name', item.name) .val(item.value).appendto($form); }); return $form; }; /** * find input fields form attribute point jquery object * */ $('form[id]').submit(function(e) { // serialize data var data = $('[form='+ this.id + ']').serializearray(); // append data form $(this).appendfield(data); }).each(function() { var form = this, $fields = $('[form=' + this.id + ']'); $fields.filter('button, input').filter('[type=reset],[type=submit]').click(function() { var type = this.type.tolowercase(); if (type === 'reset') { // reset form form.reset(); // elements outside form $fields.each(function() { this.value = this.defaultvalue; this.checked = this.defaultchecked; }).filter('select').each(function() { $(this).find('option').each(function() { this.selected = this.defaultselected; }); }); } else if (type.match(/^submit|image$/i)) { $(form).appendfield({name: this.name, value: this.value}).submit(); } }); }); })(jquery);
Comments
Post a Comment