This code : http://jsfiddle.net/bYtTG/1/
Works as I want in FF, chrome and opera, but not IE : When you click on “Calculer”, they all disable the button, except for IE.
Its seems that IE doesn’t like me to focus+blur inputs (I do that to format some read-only textbox to currency format with telerik).
Any idea on how to fix this? I don’t like onChange (plus, the Telerik controls allow you to use the keyboard up/down arrows to change an input value, which doesn’t trigger the onChange event).
html
<div>
<input id="a" value="2" /><br />
<input id="b" value="3" /><br />
<input id="c" value="" class="inactif" /><br />
<input id="d" value="5" /><br />
<input id="e" value="7" class="inactif" /><br />
<input id="total"><br /><br />
</div>
<input type="button" id="btn" value="calculer" />
js
$(document).ready(function () {
$('div input').focus(function () {
$('#btn').removeClass("inactif");
$('#btn').attr('disabled', false);
});
$('#btn').click(function () {
//L1-L2=L3
Calculer('a', '+', 'b', 'c');
Calculer('c', '-', 'd', 'total');
Calculer('d', '+', 'e', 'total');
//those line seems to be "ignored"
$('#btn').delay(500).addClass("inactif");
$('#btn').delay(200).attr('disabled', true);
});
function Calculer(idFacteur1, operande, idFacteur2, idResultat) {
var val1 = parseInt($('#' + idFacteur1).val());
var val2 = parseInt($('#' + idFacteur2).val());
var res = 0;
if (operande == "+") {
res = val1 + val2;
} else {
res = val1 - val2;
}
$('#' + idResultat).val(res);
$('#' + idResultat).focus().blur();
}
});
I fixed this with a
setTimeout