JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
入力: <input type="text" name="test" value="123abC">
JavaScript
$('input[name=test]').blur(function(){
console.log($(this).val());
var fullSize = $(this).val();
var halfSize = hankaku2Zenkaku(fullSize);
console.log(halfSize);
})
function hankaku2Zenkaku(str) {
return str.replace(/[A-Za-z0-9]/g, function(s) {
return String.fromCharCode(s.charCodeAt(0) - 0xFEE0);
});
}