In this article, we will explain to you how to remove extra space using jquery. many times we have requirements to remove white space from the textbox or many times users added unnecessary space in fields which occupied more space in the database.
I am giving you a very simple example to remove white space from the textbox. in this example, I have added one text box to add a string and one submit button and you will get output in an alert box.
So, let's see remove blank space from string jquery or javascript remove all whitespaces from a string.
<html lang="en">
<head>
<title>How to remove spaces using JQuery - websolutionstuff.com</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<div>
<h1>How to remove spaces using JQuery - websolutionstuff.com</h1>
<textarea class="content-text">
This is demo how to remove space using jquery.
</textarea>
<button>Remove Space</button>
</div>
<script type="text/javascript">
$("button").click(function(){
removeText = $(".content-text").val();
var rm_space = removeText.replace(/ /g,'');
alert(rm_space);
});
</script>
</body>
</html>
You might also like:
In this article, we will see how to create a custom error page in laravel 9. Here we will create a custom 404 error...
Feb-09-2023
Greetings, Laravel enthusiasts! Today, let's explore a practical aspect of web development – adding images to...
Dec-20-2023
Hello All, In this tutorial i will show you laravel 8 mobile number OTP authentication using firebase, There are many...
Mar-31-2021
In this article, we'll learn how to resolve the "419 page expired" error in Laravel. You might have encoun...
Jun-28-2020