jquery - Specific function to onblur of several elements -
i have function checks input , works well.
function checkinputnumber() { var inputnumber = $(this).val(), dotscount = 0, i; for(i = 0; < inputnumber.length; i++) { if( (inputnumber[i].charcodeat() >= 48 && inputnumber[i].charcodeat(0) <= 57) || (inputnumber[i].charcodeat(0) == 46)) { if((inputnumber[i].charcodeat(0) == 46)) { dotscount++; if(dotscount > 1) { $(this).val(""); } } } } }
and want add different elements on "blur" property :
$('#input1').bind('blur', checkinputnumber()); $('#input2').bind('blur', checkinputnumber());
but i'm not sure syntax. ideas/suggestions ?
$('#input1, #input2').on('blur', checkinputnumber)
Comments
Post a Comment