Saturday, 15 September 2012

jquery - why is the 'input' event firing on page refresh in IE for textarea and input (non-text) -



jquery - why is the 'input' event firing on page refresh in IE for textarea and input (non-text) -

can advise why 'input' event firing when form refreshed.

it doesn't on normal text inputs, textarea , input[type=number]

basically have textarea required, , due ie11 not applying pseudo classes correctly, have had bind events phone call validation code , manually apply valid/invalid classes.

$('[required]').on('input',function(){ checkvalid(this);}); function checkvalid(ele) { if(ele.validity.valid) { $(ele).removeclass('invalid'); $(ele).addclass('valid'); } else { $(ele).removeclass('valid'); $(ele).addclass('invalid'); } }

if refresh page, checkvalid running against textarea , input[type=number] , not normal inputs?

i have traced 'input' event firing when pages loads, after refresh , not on initial page load.

why , how stop it?

thanks, 1dmf

edit re comment

$(document).ready(function() { // hide select list placeholders $('select option:first').css('display','none'); // handle required fields ie pseudo classes don't work $('select[required]').on('click',function(){ checkvalid(this);}); $('[required]').on('input',function(){ checkvalid(this);}); $('[required]').on('invalid',function(){ $(this).addclass('invalid'); }); // add together jquery ui tooltips $('body').tooltip(); // deal ff , fact refresh doesn't blank form fields! $('[required]').each(function(){ if($(this).val() != '') { checkvalid(this); } }); });

jquery internet-explorer

No comments:

Post a Comment