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
Post a Comment