Introduction:
Description:
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.
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.
To
remove or delete spaces from string we need to use regular expression for that we
need to write codesnippet like as shown below
Remove all the spaces from string
<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>
|
If
you want check this code in sample check below code
Example:
<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>
|
Live
Demo
To check Live demo
click on below button
|
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. |
|||
|
|||
1 comments :
Note: Only a member of this blog may post a comment.