Function with jquery.alphanumeric I want to implement jquery.alphanumeric in HTML pattern, so I used a jQuery plugin from here. Can this be shortened or improved?

&lt;input type="text" char-allow="$#*" class="alpha"&gt;
&lt;input type="text" char-allow="+-" class="numeric"&gt;
&lt;input type="text" char-allow="&amp;" class="alphanumeric"&gt;

&lt;script&gt;
    function setAlphaNumeric(){
        $(".numeric").each(function(){
            var a = $(this).attr("char-allow"); $(this).numeric({allow:a});
        });
        $(".alpha").each(function(){
            var a = $(this).attr("char-allow"); $(this).alpha({allow:a});
        });
        $(".alphanumeric").each(function(){
            var a = $(this).attr("char-allow"); $(this).alphanumeric({allow:a});
        });
    }

$(function(){

setAlphaNumeric();

});
&lt;/script&gt;
It could be shortened to:

function setAlphaNumeric() {
  $(".numeric, .alpha, .alphanumeric").each(function() {
    $(this)[this.className]({
      allow: $(this).attr("char-allow")
    });
  });
}

$(setAlphaNumeric);