I want to implement jquery.alphanumeric
in HTML pattern, so I used a jQuery plugin from here. Can this be shortened or improved?
<input type="text" char-allow="$#*" class="alpha">
<input type="text" char-allow="+-" class="numeric">
<input type="text" char-allow="&" class="alphanumeric">
<script>
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();
});
</script>
data-*
custom attributes 2. Usepattern
attribute. Ex for alpha<input type="text" pattern="[a-zA-Z$#*]+" />
\$\endgroup\$