javascript - select method fails in Firefox and Chrome -
when user enters "junk" in input field 1, blur event triggers function notify them of error , select()
's field triggering error. works fine in ie , safari firefox , chrome skip right on select()
. if use firebug step through code, works designed.
here sample of code:
function checkforjunk(fld) { if (fld.value == 'junk') { alert('please take out junk'); fld.select(); } }
<form name="junk" action="junk.htm" method="post"> input1: <input type="text" name="morejunk" value="" onblur="checkforjunk(this);" /> <br> input2: <input type="text" name="evenmorejunk" value="" onblur="checkforjunk(this);" /> </form>
it works fine me on chrome when put select in settimeout
settimeout(function() { fld.select(); }, 1);
Comments
Post a Comment