(function ($) { 'use strict'; function normalize(value) { if (typeof value !== 'string') { return ''; } value = value.replace(/[A-Za-z]/g, function (ch) { return String.fromCharCode(ch.charCodeAt(0) - 65248); }); value = value.toUpperCase(); return value.replace(/[^A-Zぁ-ゖァ-ヶ一-龠々〆ヵヶー]/g, ''); } $.customerNameNormalizer = { normalize: normalize }; $.fn.customerNameNormalizer = function () { return this.each(function () { var isComposing = false; var $input = $(this); $input.on('compositionstart', function () { isComposing = true; }); $input.on('compositionend', function () { isComposing = false; this.value = normalize(this.value); }); $input.on('input blur', function () { if (isComposing) { return; } this.value = normalize(this.value); }); }); }; })(jQuery);