
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jQuery Examples &#8211; CodeInDotNet</title>
	<atom:link href="https://www.codeindotnet.com/category/jquery-examples/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codeindotnet.com</link>
	<description>C# Dot Net Programming tutorial &#38; code examples</description>
	<lastBuildDate>Tue, 02 Apr 2024 06:27:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>

<image>
	<url>https://www.codeindotnet.com/wp-content/uploads/2021/04/SiteIcon.png</url>
	<title>jQuery Examples &#8211; CodeInDotNet</title>
	<link>https://www.codeindotnet.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Hide DataTables &#8216;Search and Pagination&#8217;</title>
		<link>https://www.codeindotnet.com/disable-datatables-pagination-search-jquery/</link>
					<comments>https://www.codeindotnet.com/disable-datatables-pagination-search-jquery/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 23 Nov 2023 11:07:35 +0000</pubDate>
				<category><![CDATA[jQuery Examples]]></category>
		<guid isPermaLink="false">https://www.codeindotnet.com/?p=6348</guid>

					<description><![CDATA[If you&#8217;re using DataTables, a jQuery plugin for enhancing HTML tables, and you want to remove pagination, search, ordering and other things you can do so by configuring the DataTables options appropriately. Pagination in DataTables is controlled by the &#8220;paging&#8221; option. How to disable Datatable paging, search &#38; other options Here&#8217;s an example of how [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div id="PageInHoriAd1"></div>
<script>
fetch('https://www.codeindotnet.com/gads/PageInHoriAd1.txt')
	.then(response => response.text())
	.then(text => {
		document.getElementById('PageInHoriAd1').innerHTML = text;
	})
	.catch(error => {
		console.error('Error fetching manual PageInHoriAd1:', error);
	});
</script>



<p>If you&#8217;re using DataTables, a jQuery plugin for enhancing HTML tables, and you want to remove pagination, search, ordering and other things you can do so by configuring the DataTables options appropriately. Pagination in DataTables is controlled by the &#8220;paging&#8221; option.</p>



<br>



<h2 class="wp-block-heading h2Cust1" id="how-to-disable-datatable-paging-search-other-options"><strong>How to disable Datatable paging, search &amp; other options</strong></h2>



<br>



<p>Here&#8217;s an example of how you can initialize DataTables and disable pagination after initialization:</p>



<h4 class="wp-block-heading" id="disable-datatables-paging-search-others-after-initialization"><strong><em>disable datatables paging, search &amp; others after initialization</em>:</strong></h4>



<pre class="pchl"><code><span class="com">// set paging parameter in false on object configuration</span>

$(document).ready(<span class="key">function</span>() {
    $('<b>#dataTableId</b>').<span class="custkey">DataTable</span>( {
        "searching": <span class="key">false</span>,
        "paging":   <span class="key">false</span>,
        "ordering": <span class="key">false</span>,
        "info":     <span class="key">false</span>,
        "lengthChange":<span class="key">false</span>
    } );
} );</code></pre>



<br>



<p>Replace <strong>dataTableId </strong>with the actual ID of your table. Setting <span class="spanHT">&#8220;paging&#8221;: false</span> will disable pagination for the DataTable. <br>In the same way, setting <span class="spanHT">&#8220;searching&#8221;: false</span> will hide the search option &amp; so on.</p>



<br>



<p>Make sure you include the required DataTables JavaScript and CSS files in your HTML document. You can either download them and host them locally or include them from a CDN. Here&#8217;s an example using CDN:</p>



<h4 class="wp-block-heading" id="example-setting-pagination-false"><strong><em style="font-weight: bold;">example &#8211; setting pagination  false</em>:</strong></h4>



<pre class="pchl"><code>&lt;!DOCTYPE html>
&lt;html lang="en">
&lt;head>
    &lt;meta charset="UTF-8">
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
    &lt;title>Your Page&lt;/title>
    &lt;link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.css">
    &lt;script type="text/javascript" charset="utf8" src="https://code.jquery.com/jquery-3.6.0.min.js">&lt;/script>
    &lt;script type="text/javascript" charset="utf8" src="https://<b>cdn.datatables.net</b>/1.11.5/js/jquery.dataTables.js">&lt;/script>

    &lt;script>
        $(document).ready(<span class="key">function</span>() {
            $('<b>#dataTableId</b>').<span class="custkey">DataTable</span>({
                "paging": <span class="key">false</span>
            });
        });
    &lt;/script>

&lt;/head>
&lt;body>

<span class="com">&lt;!-- Your table goes here with the corresponding ID --></span>
&lt;table <b>id="dataTableId"</b>>
    <span class="com">&lt;!-- table content --></span>
&lt;/table>

&lt;/body>
&lt;/html>
</code></pre>



<br>



<p>Make sure to check the DataTables documentation for the version you are using, as some options may vary slightly between versions: <a href="https://datatables.net/manual/" target="_blank" rel="noopener"><strong>https://datatables.net/manual/</strong></a></p>



<div id="PageInAd1"></div>
<script>
fetch('https://www.codeindotnet.com/gads/PageInAd1.txt')
	.then(response => response.text())
	.then(text => {
		document.getElementById('PageInAd1').innerHTML = text;
	})
	.catch(error => {
		console.error('Error fetching manual PageInAd1:', error);
	});
</script>



<br>



<br>
<script src="/my-js/latesttop10post.js" type="text/javascript"></script>
<input type="hidden" id="cids" value="129,138,103,140,139">
<div id="latestPostlist"></div>
<br>



<div class="wp-block-rank-math-toc-block toc-cust" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#how-to-disable-datatable-paging-search-other-options">How to disable Datatable paging, search &amp; other options</a><ul><li><a href="#disable-datatables-paging-search-others-after-initialization">disable datatables paging, search &amp; others after initialization:</a></li><li><a href="#example-setting-pagination-false">example &#8211; setting pagination  false:</a></li></ul></li></ul></nav></div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codeindotnet.com/disable-datatables-pagination-search-jquery/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Removing Spaces Validation from Input Field via jQuery</title>
		<link>https://www.codeindotnet.com/remove-spaces-from-input-jquery-validation/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 28 Aug 2023 15:51:19 +0000</pubDate>
				<category><![CDATA[jQuery Examples]]></category>
		<category><![CDATA[Javascript]]></category>
		<guid isPermaLink="false">https://www.codeindotnet.com/?p=4728</guid>

					<description><![CDATA[Removing Spaces from the Input field through jQuery validation Removing spaces from user input is a good practice in maintaining data integrity and providing a seamless user experience in your web applications. You can easily implement a solution to remove spaces from input fields with the help of jQuery. In this article, we&#8217;ll discuss why [&#8230;]]]></description>
										<content:encoded><![CDATA[
<style>
.h3Cust {
    border-left: 5px solid #6A4097;
    padding-left: 6px;
    font-weight: bold;
}
</style>



<div id="PageInAd1"></div>
<script>

fetch('https://www.codeindotnet.com/gads/PageInAd1.txt')
	.then(response => response.text())
	.then(text => {
		document.getElementById('PageInAd1').innerHTML = text;
	})
	.catch(error => {
		console.error('Error fetching manual PageInAd1:', error);
	});
</script>



<h2 class="wp-block-heading"><strong>Removing Spaces from the Input field through jQuery validation</strong></h2>



<p class="custp1">Removing spaces from user input is a good practice in maintaining data integrity and providing a seamless user experience in your web applications. You can easily implement a solution to remove spaces from input fields with the help of jQuery. In this article, we&#8217;ll discuss why space removal is important, and provide you with a step-by-step guide and a full sample code to achieve this using jQuery.</p>



<br>



<h2 class="wp-block-heading"><strong>The Importance of Removing Spaces from Input</strong></h2>



<p class="custp1">Spaces in user input might not appear to be a big concern at first glance. However, they can have several negative impacts:</p>



<ol class="wp-block-list">
<li><strong>Data Consistency</strong>: Spaces within input fields can lead to inconsistencies in data. For instance, if you&#8217;re dealing with usernames or codes, spaces can be erroneously included, causing issues during search and retrieval.</li>



<li><strong>Front-end and Back-end Consistency</strong>: Spaces can introduce discrepancies between the front-end and back-end of your application. Data with spaces might be displayed correctly on the front-end but cause errors when processed on the back-end.</li>



<li><strong>User Experience</strong>: Users might unintentionally add leading or trailing spaces to their input, resulting in frustration when their input is not accepted or processed as expected.</li>
</ol>



<br>



<h2 class="h2Cust1"><strong>Implementing Space Removal with jQuery</strong></h2>



<p class="custp1">Here&#8217;s a step-by-step guide to implementing space removal from input fields using jQuery:</p>



<h3 class="h3Cust"><strong>Step 1: Include jQuery in Your Project</strong></h3>



<p class="custp1">Before you start, ensure you have included the jQuery library in your project. You can do this by adding the following code within the <span class="spanHT">&lt;head&gt;</span> section of your HTML document:</p>



<pre class="pchl"><code>&lt;script src="https://code.jquery.com/jquery-3.7.0.min.js"&gt;&lt;/script&gt;
</code></pre>



<p>Make sure to replace the URL with the appropriate version of jQuery if needed.</p>



<br>



<h3 class="h3Cust"><strong>Step 2: Create the HTML Input Element</strong></h3>



<p class="custp1">Create an input element in your HTML where users can enter text. Assign it an ID for easy identification:</p>



<pre class="pchl"><code>&lt;input type="text" id="inputField" placeholder="Enter text..."&gt;
</code></pre>



<br>



<h3 class="h3Cust"><strong>Step 3: Implement the jQuery Function</strong></h3>



<p class="custp1">Now, let&#8217;s write the jQuery code that will remove spaces from the input field:</p>



<pre class="pchl"><code>
&lt;script&gt;
$(document).ready(<span class="key">function</span>() {
    $('#inputField').on('input', <span class="key">function</span>() {
        <span class="key">var</span> inputValue = $(this).val();
        <span class="key">var</span> removedSpacesValue = inputValue.replace(/\s/g, ''); // Remove all spaces
        $(this).val(removedSpacesValue);
    });
});
&lt;/script&gt;

</code></pre>



<br>



<div>In this code snippet:</div>



<ul>

<li><span class="spanHT">$(document).ready(function() { &#8230; });</span> ensures that the jQuery code executes after the DOM is fully loaded.</li>

<li><span class="spanHT">$(&#8216;#inputField&#8217;).on(&#8216;input&#8217;, function() { &#8230; });</span> attaches an event listener to the input field that triggers whenever the input value changes.</li>

<li><span class="spanHT">var inputValue = $(this).val();</span> retrieves the current value of the input field.</li>

<li><span class="spanHT">var removedSpacesValue = inputValue.replace(/\s/g, &#8221;);</span> uses a regular expression to replace all spaces (<span class="spanHT">\s</span>) with an empty string globally (<span class="spanHT">g</span>).</li>

<li><span class="spanHT">$(this).val(removedSpacesValue);</span> sets the input field&#8217;s value to the new value without spaces.</li>

</ul>



<br>



<h3 class="h3Cust"><strong>Step 4: Test Your Implementation</strong></h3>



<p class="custp1">Open your HTML document in a web browser. As you type into the input field, spaces will be automatically removed, providing a smooth user experience while ensuring data consistency.</p>



<br><br>



<h2 class="h2Cust1"><strong>Full Sample Code &#8211; <em>HTML &amp; jQuery validation</em></strong></h2>



<p class="custp1">Here&#8217;s the complete HTML document incorporating the jQuery space removal functionality:</p>



<pre class="pchl"><code>
&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta charset="UTF-8"&gt;
&lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
&lt;title&gt;Space Removal with jQuery&lt;/title&gt;
<span style="background:#f2f19d;">&lt;script src="https://code.jquery.com/jquery-3.6.0.min.js"&gt;&lt;/script&gt;</span>
&lt;/head&gt;
&lt;body&gt;

<span style="background:#f2f19d;">&lt;input type="text" id="inputField" placeholder="Enter text..."&gt;</span>

&lt;script&gt;
$(document).ready(<span class="key">function</span>() {
    $('#inputField').on('input', <span class="key">function</span>() {
        <span class="key">var</span> inputValue = $(this).val();
        <span class="key">var</span> removedSpacesValue = <span style="background:#f2f19d;">inputValue.replace(/\s/g, '')</span>;
        $(this).val(removedSpacesValue);
    });
});
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;

</code></pre>



<div id="PageInAd2"></div>
<script>
fetch('https://www.codeindotnet.com/gads/PageInAd2.txt')
	.then(response => response.text())
	.then(text => {
		document.getElementById('PageInAd2').innerHTML = text;
	})
	.catch(error => {
		console.error('Error fetching manual PageInAd2:', error);
	});
</script>



<br>



<div style="padding: 0.625rem 1.25rem 1.25rem 1.25rem; box-shadow: 0.0625rem 0.0625rem 0.9375rem 0rem lightgrey; margin-bottom: 1.25rem; border-radius: 0.625rem;">
	<div><span style="border-bottom: 0.0625rem solid #cd5c5c; color:#cd5c5c;"><b><i>also read:</i></b></span>
		<div style="padding-left:0.9375rem; padding-top:0.625rem; line-height: 1.9;">
			<div><b>&#8211; <a href="https://www.codeindotnet.com/difference-between-window-location-href-and-window-location-replace-and-window-location-assign-in-javascript/">Difference between window.location.href, window.location.replace, and window.location.assign in JavaScript</a></b></div>
<div><b>&#8211; <a href="https://www.codeindotnet.com/read-html-tags-from-url-as-text-in-javascript/">Read HTML Tags from URL as text file and insert them into an existing element &#8211; Javascript</a></b></div><div><b>&#8211; <a href="https://www.codeindotnet.com/read-text-files-from-url-javascript-jquery/">Different Ways to Read Text Files from URLs using JavaScript and jQuery</a></b></div><div><b>&#8211; <a href="https://www.codeindotnet.com/check-ckeditor-version-in-javascript/">Check CKEditor Version in JavaScript</a></b></div>
<div><b>&#8211; <a href="https://www.codeindotnet.com/how-to-check-if-an-element-is-hidden-in-jquery/">How to check if an element is hidden in jQuery?</a></b></div><div><b>&#8211; <a href="https://www.codeindotnet.com/find-if-element-is-hidden-visible-javascript/">Javascript: find out if Element is hidden or visible</a></b></div><div><b>&#8211; <a href="https://www.codeindotnet.com/6-ways-to-redirect-to-another-page-javascript/">6 ways to redirect to another page in JavaScript</a></b></div><div><b>&#8211; <a href="https://www.codeindotnet.com/show-javascript-popup-in-page-using-html-div-element-css/">Show JavaScript Popup in a webpage using Div Elements &amp; CSS</a></b></div><div><b>&#8211; <a href="https://www.codeindotnet.com/find-public-ip-address-via-javascript/">Easy way to find Public IP Address: Javascript Code</a></b></div>
		</div>
	</div>
</div>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
