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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -