JSFiddle - React, Tailwind, and code Playground
by Frank Liu
HTML
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<p>Name: <input id="reg-name" type="text" name="user"></p>
<p>Name: <input id="user-email" type="email" name="user"></p>
<button>Set the value of the input field</button>
</body>
</html>
JavaScript
$(document).ready(function(){
$("#reg-name, #first-name, #last-name, #user-email").change(function(){
let expectVal = $(this).val().trim();
$(this).val(expectVal);
});
});