JSFiddle - React, Tailwind, and code Playground
Remove Preceding & Trailing white space from fields
HTML
<input id="one" type="text">
<input id="two" type="text">
CSS
body { margin: 50px; }
JavaScript
jQuery(function ($) {
// Remove Preceding & Trailing white space
$('#one, #two').bind('keyup change', function(e) {
$(this).val($(this).val().replace(/^\s\s*/, '').replace(/\s\s*$/, ''));
});
});