In previous articles I explained jQuery Remove first/last character from string, Best Drag and Drop Plugin examples, Scroll back to top plugin Examples, Password strength jquery plugin examples and many articles relating to JQuery. Now I will explain how to remove or delete spaces from string using JQuery in asp.net.
<script type="text/javascript">
$(document).ready(function()
{
var str = ' Welcome To
Aspdotnet - Suresh '
var newstr = str.replace(/\s/g,'')
// Remove spaces from string
alert(newstr);
})
</script>
|
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"
runat="server">
<title>jQuery Remove or Delete spaces from string in asp.net</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
</head>
<body>
<form id="form1"
runat="server">
<div>
String : <b>Welcome To
Aspdotnet - Suresh</b>
<input type="button" id="btnRemove" value="Remove Spaces From String" /><br /><br />
</div>
<script type="text/javascript">
$(document).ready(function()
{
$('#btnRemove').click(function() {
var str = ' Welcome To
Aspdotnet - Suresh '
var newstr = str.replace(/\s/g, '')
// Remove spaces from string
alert(newstr);
});
});
</script>
</form>
</body>
</html>
|
|
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|
Subscribe by RSS
Subscribe by Email
1 comments :