Is it possible to create a jQuery function that plays around with the name of the selector?
<p>I am trying to make a counter for "Number of characters left" in a form:</p>

<pre><code>&lt;input type="text" id='username_input'&gt;
&lt;input type="text" id='password_input'&gt;
</code></pre>

<p>Is it possible to make a function whose parameter will be part of the selector? 
So you can understand my question better, I'll show you an example that I did, and that doesn't work.</p>

<p>What I'm trying to do will seem obvious. This implies I have to standardize all id's. 
I'm aware I could make a maxChar parameter in the function, but I left my mistake <code>field+'_maxChar'</code> so that you can tell me why it's not possible.</p>

<p>THanks a lot in advance</p>

<pre><code>var username_maxChar=20,password_maxChar=30;

function countLeft(field,minCharacters){
$('#'+field+'_input').keyup(function(){
    var input_length = $('#'+field+'_input').val().length;
    var input_count = field+'_maxChar' - input_length;
    $('#'+field+'_counter').text(input_count);


    }); 
    }

countLeft(username,6);
</code></pre>
