JQuery: attach the same callback to one or more elements -


i have prevent user insert letters in numeric fields. use this:

 $('input[name=myinput]').live('keyup', function() {                 var $th = $(this);                 $th.val($th.val().replace(/[^0-9,\.]/g, ''));         }); 

how list other input fields? (i can't use $('input'))

i tried

$('input[name=myinput],input[name=myinput2]').live('keyup', function() {                 var $th = $(this);                 $th.val($th.val().replace(/[^0-9,\.]/g, ''));         }); 

but input[name=myinput] accepted.

you should use class on input element , do:

$('input.ekeyup').live('keyup', function() {     var $th = $(this);     $th.val($th.val().replace(/[^0-9,\.]/g, '')); }); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -