.dnkl_onlyAlpha()

.dnkl_onlyAlpha()

This jQuery plugin makes an input field only contain alpha characters.

jQuery.fn.dnkl_onlyAlpha = function() {
    /*
	NAME:	dnkl_onlyAlpha()
	VERS:	1.0
	DESC:	Removes non-alpha characters from value
	USAGE:	$('#myInputID').dnkl_onlyAlpha();
    */
    return $(this).each(function() {
        $(this).keyup(function() {
            var reg = new RegExp('[^A-z]');
            if ($(this).val().match(reg)) {
                $(this).val($(this).val().replace(/[^\-A-z]/g, ''));
            }
        });
    });
}

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>