Skip to content

Instantly share code, notes, and snippets.

@yashasvi9199
Created June 7, 2023 16:23
Show Gist options
  • Save yashasvi9199/abf9e0249d1f8f4e8195bcfae7a31dcb to your computer and use it in GitHub Desktop.
Save yashasvi9199/abf9e0249d1f8f4e8195bcfae7a31dcb to your computer and use it in GitHub Desktop.
Trim space from beginning and end in input text field
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
</head>
<body>
<h2>Please Enter Input</h2>
<input type="text" placeholder="Enter input" onblur="trimmer(this.value)">
<script>
function trimmer(val) {
var replace = $.trim(val);
$("input").val(replace);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment