jQuery, same function for multiple ids
<p>i want to clear specified input if the value is not number. function works for one ID, but i want it to work for multiple. of course i can write function multiple times but i dont want to do that.</p>

<p>the following code gets effect only for input with id "d". i dont know how to identify other ids. can anyone help?</p>

<pre><code>&lt;input id="d" /&gt;

&lt;input id="d2" /&gt;

&lt;input id="d3" /&gt;

&lt;script type="text/javascript"&gt;

$('#d,d2,d3').keyup(function(){

if($('#d,d2,d3').val() != "") {

    var value = $('#d,d2,d3').val().replace(/^\s\s*/, '').replace(/\s\s*$/, '');

    var intRegex = /^\d+$/;

    if(intRegex.test(value)) {}

    else {


    $(this).val('');

    }



}

});

&lt;/script&gt;
</code></pre>
