IE9 focus fails unless an extra line is added. Is this an IE9 bug or a jQuery bug?
I have a column of input fields that I validate for numbers only. If it's a NaN I want to display a message and refocus when the user tries to click away.
The following code will fail in IE9 to refocus back to the offending value. But I had to insert (by pure accident) an extra random focus line to force it to focus correctly. Any ideas?
- <input type='text' class='unit' value=""/>
- $("input[class=unit]").change(function(){
- if ( !isInt($(this).val()) || Number($(this).val())<0 ) {
- alert("Not an integer "+$(this).val());
- var oldUnits=$(this).data('oldUnits');
- $(this).val(oldUnits);
- $('#unit1').focus(); // fix for IE9 not focusing
-
- $(this).focus();
- return false;
- }
- });