gagandeepbedi
Technical User
I have First Name and Last Name in the same input box and I am looking for the javascript code that would trim any extra spaces between the first and the last name, before the first name and after the last name.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
function inputWSpace(myInput) {
myInput.value=myInput.value.replace(/(\s)\s+/, "$1").replace(/^\s*/, "").replace(/\s*$/, "");
}
myInput
input
<form>
<input type="text" ondblclick="inputWSpace(this)">
</form>
[code]
After entering text into the above [code]input
inputWSpace
function inputWSpace(myInput) {
myInput.value=myInput.value.replace(/(\s)\s+/g, "$1").replace(/^\s*/, "").replace(/\s*$/, "");
}