pTutorial

New way to learn Programming

JQuery remove all spaces

How to remove all spaces in jquery

In this article we demonstrate how to remove Spaces from the string by using Jquery and Javacript with the help of live example. The following JQuery Script can be used to remove spaces from the character.

Remove all spaces Jquery example


<!DOCTYPE html>
<html>
<head>
<script src="http://freeonlinecompiler.ptutorial.com
/js/jquery.min.js"></script>
<script>
$(document).ready(function (e) {
$('#kk').click(function () {
var z = $('#uk').val();
if(z==''){
$("#divData").text("Please enter something first");	
return false;
}else{
var z1 = z.replace(/\s+/g, '');
$("#divData").text(z1);
return false;
}
})
});
</script>
<style>
table{
border: 1px solid #080808;
margin: 5px;
padding: 10px;
}

</style>
</head>
<body>
<h4>Remove All spaces</h4>
<table id="tab">
<tr>
</tr>
<tr>
<td>Enter Name *</td>
<td> <input type="text" id="uk" name="kk1"></td>
</tr>
<tr>
<td> <input type="submit" id="kk" value="Check"></td>
</tr>
</table>

<div id="divData"></div>
</body>
</html>


Download

See Also


QUOTES OF THE DAY

The heart of melody can never be put down.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER