<?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 Tutorial: Learn jQuery For Free with example | Atcodex</title>
	<atom:link href="https://atcodex.com/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>https://atcodex.com/jquery/</link>
	<description>Achieve financial success without sacrificing well-being! AtCodex provides actionable strategies for managing money, time, and personal growth—all in one place.</description>
	<lastBuildDate>Sun, 10 Oct 2021 08:04:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://atcodex.com/wp-content/uploads/2020/05/cropped-New-Project-1-32x32.png</url>
	<title>jQuery Tutorial: Learn jQuery For Free with example | Atcodex</title>
	<link>https://atcodex.com/jquery/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Check Atleast One Checkbox is Checked or Not in JQuery?</title>
		<link>https://atcodex.com/how-to/how-to-check-atleast-one-checkbox-is-checked-or-not-in-jquery/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Thu, 07 Oct 2021 08:02:15 +0000</pubDate>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[jQuery]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=1530</guid>

					<description><![CDATA[<p>In this tutorial, we will show you how to check at least one checkbox is checked or not in jquery. We have tried to explain this simple step by step. &#8230; </p>
<p>The post <a href="https://atcodex.com/how-to/how-to-check-atleast-one-checkbox-is-checked-or-not-in-jquery/">How to Check Atleast One Checkbox is Checked or Not in JQuery?</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In this tutorial, we will show you how to check at least one checkbox is checked or not in <a href="https://jquery.com/" target="_blank" rel="noreferrer noopener">jquery</a>.  We have tried to explain this simple step by step. you can see jquery for least one checkbox checked. </p>



<p class="wp-block-paragraph">we have used a <strong>form selector</strong> to target the form and a function will execute whenever someone tries to submit the form. This function will check if at least one check box is checked or not.</p>



<p class="wp-block-paragraph">we have used if the condition inside this function if at least one input type checkbox is check, the condition will output true. For this purpose input:checkbox selector is used to selecting all the checkboxes to check which checkbox is checked.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">let&#8217;s see bellow example:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;!DOCTYPE html>
&lt;html>
&lt;head>
    &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js">&lt;/script>
&lt;/head>
&lt;body>
  
&lt;div>
    &lt;h1>How to check atleast one checkbox is checked or not in JQuery&lt;/h1>
    &lt;strong>Colors:&lt;/strong>
  
    &lt;input type="checkbox" value="true" class="color-check" name="colors[]"> Red
    &lt;input type="checkbox" value="true" class="color-check" name="colors[]"> Blue
    &lt;input type="checkbox" value="true" class="color-check" name="colors[]"> Black
    &lt;input type="checkbox" value="true" class="color-check" name="colors[]"> Orange
  
    &lt;button class="submit">Submit&lt;/button>
&lt;/div>
  
&lt;script type="text/javascript">
    $(".submit").click(function(){
         if($('.color-check').filter(':checked').length &lt; 1){
                alert("Please Check at least one Color Box");
                 return false;
         }else{
             alert("Proceed");
         }
    });
&lt;/script>
  
&lt;/body>
&lt;/html></pre>



<p class="wp-block-paragraph">Hope you liked it.</p>



<h2 class="wp-block-heading">Recommended Posts For You</h2>



<ul class="wp-block-list"><li><a href="https://atcodex.com/php/remove-multiple-elements-from-an-array-in-javascript-jquery/" target="_blank" rel="noreferrer noopener">Remove multiple elements from an array in Javascript/jQuery</a></li><li><a href="https://atcodex.com/how-to/select-box-with-search-option-in-jquery-with-example/" target="_blank" rel="noreferrer noopener">Select box with search option in Jquery with example</a></li><li><a href="https://atcodex.com/how-to/how-to-enable-and-disable-the-submit-button-using-jquery/" target="_blank" rel="noreferrer noopener">How to enable and disable the submit button using jQuery?</a></li></ul>
<p>The post <a href="https://atcodex.com/how-to/how-to-check-atleast-one-checkbox-is-checked-or-not-in-jquery/">How to Check Atleast One Checkbox is Checked or Not in JQuery?</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Remove multiple elements from an array in Javascript/jQuery</title>
		<link>https://atcodex.com/php/remove-multiple-elements-from-an-array-in-javascript-jquery/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Mon, 28 Sep 2020 17:31:11 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[Lodash]]></category>
		<category><![CDATA[Underscore]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=1045</guid>

					<description><![CDATA[<p>In this post, we will learn how to Remove multiple elements from an array using Javascript or jQuery give with an example. We can simply remove elements from an array &#8230; </p>
<p>The post <a href="https://atcodex.com/php/remove-multiple-elements-from-an-array-in-javascript-jquery/">Remove multiple elements from an array in Javascript/jQuery</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In this post, we will learn how to Remove multiple elements from an array using Javascript or jQuery give with an example. We can simply remove elements from an array using javascript. Below in the post, we have tried different methods to do the same.</p>



<p class="wp-block-paragraph">Let&#8217;s suppose we have an array in which and we want to remove some particular element from the array without refreshing the page.  In that case, we have to use javascript and jquery to remove the element from the array. Because if we go for server-side language then we have to refresh the page or need to get done the same thing with the help of AJAX and backend language. Which is a kind of long and boring task to do. We can simply use javascript, jquery, and some of the other javascript libraries to do it.</p>



<p class="wp-block-paragraph">Following are the some example we are providing to make you  understand about the topic.</p>



<h2 class="wp-block-heading">Remove element using Vanilla JavaScript</h2>



<p class="wp-block-paragraph">In first, let&#8217;s remove the element using simple javascript and jquery, In this, we will use Array.prototype.remove, grep() and inArray() to remove multiple as well as the duplicate value from the array in jquery. However, you can check <a href="https://atcodex.com/how-to/how-to-remove-duplicate-values-from-an-array-in-php/" target="_blank" rel="noreferrer noopener">How to remove duplicate values from an array in PHP</a></p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;!DOCTYPE html>
&lt;html>
&lt;head>
   &lt;title>Jquery Remove Multiple Values from Array Example&lt;/title>
   &lt;script src="https://code.jquery.com/jquery-1.12.4.js">&lt;/script>
&lt;/head>
&lt;body>
  
&lt;script type="text/javascript">
    var sites = [ "website1.com", "website2.com", "website3.com", "website4.com" ];
  
    Array.prototype.remove = function(){
        var args = Array.apply(null, arguments); 
   
        return $.grep(this, function(value) {
           return $.inArray(value, args) &lt; 0;
        });
    }
  
    sitesNew = sites.remove("website2.com", "website3.com");
  
    console.log(sitesNew);
&lt;/script>
  
&lt;/body>
&lt;/html></pre>



<p class="wp-block-paragraph">Output</p>



<figure class="wp-block-image size-large is-resized is-style-default"><img fetchpriority="high" decoding="async" src="https://atcodex.com/wp-content/uploads/2020/09/Untitled.png" alt="output in console" class="wp-image-1056" width="590" height="330" srcset="https://atcodex.com/wp-content/uploads/2020/09/Untitled.png 590w, https://atcodex.com/wp-content/uploads/2020/09/Untitled-300x168.png 300w" sizes="(max-width: 590px) 100vw, 590px" /></figure>



<h2 class="wp-block-heading">Remove element using Using Lodash</h2>



<p class="wp-block-paragraph">To remove an element, we can use an external javascript library called Lodash. Lodash has the <code><a href="https://lodash.com/docs/#remove" target="_blank" rel="noreferrer noopener">remove</a>()</code> method which is very easy to use. All other methods in the Lodash are very easy to use and helpful which can done job for you in a second. You do not need to break the array  and manipulate for getting some work done in javascript. It have very helpful built in methods which you can use in any situation in the programming.</p>



<p class="wp-block-paragraph">In the below code  we are just passing the array in _.remove() and in which we have defined callback function when passed argument is == to 3.  </p>



<p class="wp-block-paragraph"><strong>NOTE : It make the changes in the existing array value</strong>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">var arr = [1, 2, 3, 3, 4, 5];
_.remove(arr, function(e) {
    return e === 3;
});
console.log(arr);

// Output:
// [ 1, 2, 4, 5 ]</pre>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading">Remove element using Using Underscore</h2>



<p class="wp-block-paragraph">We can use Underscore library to solve the same problem. It has _.reject method which is same like _.remove() method in the Lodash. It works similarly like Lodash with some difference which is : it returns the new array after removing the passed value in the array. Old array value remains same. </p>



<p class="wp-block-paragraph">See the following code for an example:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">var arr = [1, 2, 3, 3, 4, 5];
var ret = _.reject(arr, function(e) {
    return e === 3;
});
console.log(arr);
console.log(ret);

// Output:
// [ 1, 2, 3, 3, 4, 5 ]
// [ 1, 2, 4, 5 ]
</pre>



<h2 class="wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">We have explained 3 different method and by using them you can remove the one or more elements from the array in simple way. I hope you guys have liked the post, if you have any suggestion please comment below., i would love to help you.</p>
<p>The post <a href="https://atcodex.com/php/remove-multiple-elements-from-an-array-in-javascript-jquery/">Remove multiple elements from an array in Javascript/jQuery</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>jQuery crop and resize an image before upload using PHP</title>
		<link>https://atcodex.com/php/jquery-crop-and-resize-an-image-before-upload-using-php/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Sat, 29 Aug 2020 17:18:34 +0000</pubDate>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=861</guid>

					<description><![CDATA[<p>Sometimes we need to upload the image to the server with the image crop option. For example, nowadays we can see that most of the website like Facebook, twitter give &#8230; </p>
<p>The post <a href="https://atcodex.com/php/jquery-crop-and-resize-an-image-before-upload-using-php/">jQuery crop and resize an image before upload using PHP</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Sometimes we need to upload the image to the server with the image crop option. For example, nowadays we can see that most of the website like Facebook, twitter give the option to set the profile picture in circular thumbnail way. You do not get the option to upload your whole profile pic. The picture has to be cropped in a circular and thumbnail format.</p>



<p class="wp-block-paragraph">In this tutorial, we are going to explain the same thing using the <strong>Croppie </strong>plugin.  In this PHP tutorial, we are going to crop an image using jQuery <strong>Croppie </strong>plugin and upload the image via Ajax request in PHP.</p>



<h2 class="wp-block-heading">What is Croppie plugin?</h2>



<p class="wp-block-paragraph"><strong><a href="https://foliotek.github.io/Croppie/">Croppie</a> </strong>is an HTML5 canvas-based image cropping library that lets you create a square or circular view of the image and allow you to crop the image with its simple and easy click and crop interface. It is very easy to use and allows the user to navigate on image and crop the only part of the image that the user wants. </p>



<p class="wp-block-paragraph">I have used it and found it very useful, even I have used it in my personal project. You should give it a try, so let&#8217;s move forward and start to know how it works. </p>



<h2 class="wp-block-heading">Use of Croppie plugin to crop the image </h2>



<p class="wp-block-paragraph">This is a common requirement in all modern web applications where you upload the images, crop the images as required for profile picture or media galleries as a thumbnail.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Create index.html</p></blockquote>



<p class="wp-block-paragraph">In this step, we will create a HTML file &#8220;index.html&#8221; and include the required library for this example.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="html" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;html lang="en">
&lt;head>
  &lt;title>PHP and jQuery - Crop Image and Upload using Croppie plugin - atcodex&lt;/title>
   &lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.min.css">
  &lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/croppie/2.6.2/croppie.min.css">
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js">&lt;/script>
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/croppie/2.6.2/croppie.js">&lt;/script>

  &lt;meta name="csrf-token" content="{{ csrf_token() }}">
&lt;/head>

&lt;body>
&lt;div class="container">
  &lt;div class="card" style="max-height: 500px;">
    &lt;div class="card-header bg-info">PHP and jQuery - Crop Image and Upload using Croppie plugin&lt;/div>
    &lt;div class="card-body">

      &lt;div class="row">
        &lt;div class="col-md-4 text-center">
        &lt;div id="upload-demo">&lt;/div>
        &lt;/div>
        &lt;div class="col-md-4" style="padding:5%;">
        &lt;strong>Select image to crop:&lt;/strong>
        &lt;input type="file" id="image">

        &lt;button class="btn btn-success btn-block btn-upload-image" style="margin-top:2%">Upload Image&lt;/button>
        &lt;/div>

        &lt;div class="col-md-4">
        &lt;div id="preview-crop-image" style="background:#9d9d9d;width:300px;padding:50px 50px;height:300px;">&lt;/div>
        &lt;/div>
      &lt;/div>

    &lt;/div>
  &lt;/div>
&lt;/div>


&lt;script type="text/javascript">


var resize = $('#upload-demo').croppie({
    enableExif: true,
    enableOrientation: true,    
    viewport: { // Default { width: 100, height: 100, type: 'square' } 
        width: 200,
        height: 200,
        type: 'circle' //square
    },
    boundary: {
        width: 300,
        height: 300
    }
});


$('#image').on('change', function () { 
  var reader = new FileReader();
    reader.onload = function (e) {
      resize.croppie('bind',{
        url: e.target.result
      }).then(function(){
        console.log('jQuery bind complete');
      });
    }
    reader.readAsDataURL(this.files[0]);
});


$('.btn-upload-image').on('click', function (ev) {
  resize.croppie('result', {
    type: 'canvas',
    size: 'viewport'
  }).then(function (img) {
    $.ajax({
      url: "upload.php",
      type: "POST",
      data: {"image":img},
      success: function (data) {
        html = '&lt;img src="' + img + '" />';
        $("#preview-crop-image").html(html);
      }
    });
  });
});


&lt;/script>


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



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Create <strong>upload.php</strong></p></blockquote>



<p class="wp-block-paragraph">Now we will create a PHP file &#8220;<strong>upload</strong>.php&#8221; to move the cropped images into a folder, so create a &#8220;uploads&#8221; folder, where are our upload file will be saved. You can change it to some other location as you want.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="php" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?php
$image = $_POST['image'];

list($type, $image) = explode(';',$image);
list(, $image) = explode(',',$image);

$image = base64_decode($image);
$image_name = time().'.png';
file_put_contents('uploads/'.$image_name, $image);

echo 'successfully uploaded';

?></pre>



<h2 class="wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">I think the Croppie plugin is very simple and easy to crop the image. The interface and functioning of the plugin are easy. You can crop any type of images like JPG, JPEG, PNG, etc. </p>



<p class="wp-block-paragraph">If you have any doubts  or any query related to this post, please do comment below and let me know, I would love to help you guys. You can also check <a href="https://atcodex.com/php/how-to-upload-a-file-with-javascript-and-php/">How to upload a file with JavaScript and PHP</a></p>
<p>The post <a href="https://atcodex.com/php/jquery-crop-and-resize-an-image-before-upload-using-php/">jQuery crop and resize an image before upload using PHP</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Select box with search option in Jquery with example</title>
		<link>https://atcodex.com/how-to/select-box-with-search-option-in-jquery-with-example/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Sat, 01 Aug 2020 15:39:56 +0000</pubDate>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[jQuery]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=592</guid>

					<description><![CDATA[<p>When it comes to select the data from the drop-down list, if there is no searching in a select box, then it creates little bit trouble for users to navigate &#8230; </p>
<p>The post <a href="https://atcodex.com/how-to/select-box-with-search-option-in-jquery-with-example/">Select box with search option in Jquery with example</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">When it comes to select the data from the drop-down list, if there is no searching in a select box, then it creates little bit trouble for users to navigate on proper data. So it is recommended to keep the searching option in the select box if there are large data. </p>



<p class="wp-block-paragraph">Today we are going to share the post about a plugin name Chosen Plugin for the select box. It is very simple and easy to integrate into the project. </p>



<p class="wp-block-paragraph">You have to include required JS and CSS in the main file and need to add the <em><strong>chosen </strong></em>class in the select box where you need searching. </p>



<p class="wp-block-paragraph">The following is complete code, <em><strong>how to integrate search option in select box.</strong></em></p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;html lang="en">
&lt;head>
    &lt;title>Select box with search option in Jquery with example&lt;/title>  
    &lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.5.1/chosen.min.css">
    &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js">&lt;/script>
    &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.5.1/chosen.jquery.min.js">&lt;/script>
&lt;/head>
&lt;body>

    &lt;div style="width:500px;margin:0px auto;margin-top:30px;">
        &lt;h2> Select box with search option in Jquery with example &lt;/h2>
        &lt;select class="chosen" style="width:500px;">
        &lt;option>HTML&lt;/option>
        &lt;option>CSS&lt;/option>
        &lt;option>JavaScript&lt;/option>
        &lt;option>PHP&lt;/option>
        &lt;option>Jquery&lt;/option>
        &lt;option>PHP Class&lt;/option>
        &lt;option>Python&lt;/option>
        &lt;option>Go&lt;/option>
        &lt;option>Ruby&lt;/option>
        &lt;/select>
        &lt;/div>

&lt;script type="text/javascript">
      $(".chosen").chosen();
&lt;/script>

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



<h2 class="wp-block-heading"><strong>How to</strong>&nbsp;select&nbsp;<strong>multiple options from a drop-down list</strong>&nbsp;<strong>in HTML</strong></h2>



<p class="wp-block-paragraph">You can also integrate the multiple select options. For that, you only need to add <strong><em>multiple</em></strong> in select box &nbsp;</p>



<pre class="wp-block-code"><code>&lt;select class="chosen" multiple></code></pre>



<p class="wp-block-paragraph">You can find more detail about the plugin at <a href="https://harvesthq.github.io/chosen/">https://harvesthq.github.io/chosen/</a></p>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link" href="https://atcodex.com/demo/Select-box-with-search-option-in-Jquery-with-example/" target="_blank" rel="noreferrer noopener">DEMO</a></div>
</div>
<p>The post <a href="https://atcodex.com/how-to/select-box-with-search-option-in-jquery-with-example/">Select box with search option in Jquery with example</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>jQuery ajax image upload in PHP with preview</title>
		<link>https://atcodex.com/php/jquery-ajax-image-upload-in-php-with-preview/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Fri, 31 Jul 2020 19:54:37 +0000</pubDate>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ajax]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=579</guid>

					<description><![CDATA[<p>In PHP it is very easy to upload files on the server with the help of the move_uploaded_file()&#160;method. But in that, you have to load the page again and again &#8230; </p>
<p>The post <a href="https://atcodex.com/php/jquery-ajax-image-upload-in-php-with-preview/">jQuery ajax image upload in PHP with preview</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In PHP it is very easy to upload files on the server with the help of the <em><strong>move_uploaded_file()&nbsp;</strong></em>method. But in that, you have to load the page again and again if you need to upload more images. Nowadays we know that speed plays a very important role in a web application, user skips and gets irritates if the page reloads every time when we do some activity on the website.</p>



<p class="wp-block-paragraph">AJAX is popular because we don&#8217;t need to reload the page in getting done something.  We are now going to discuss <strong><em>how we can upload an image using ajax and PHP with preview</em></strong>.</p>



<p class="wp-block-paragraph">When we use AJAX in the right way, it will improve the user experience. In this post, we will let you know how you can upload image using AJAX and can show preview of image without the page refresh.</p>



<h2 class="wp-block-heading">Image Upload HTML</h2>



<p class="wp-block-paragraph">This is the HTML code to upload the file and display the uploaded image preview. When users click on the Upload button, ajax will upload the file to the folder and fetch it to display on <strong><em>id=&#8221;img&#8221;</em></strong>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="html" data-enlighter-theme="wpcustom" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  &lt;div class="container">
            &lt;form method="post" action="" enctype="multipart/form-data" id="myform">
                &lt;div class='preview'>
                    &lt;img src="" id="img" width="100" height="100">
                &lt;/div>
                &lt;div >
                    &lt;input type="file" id="file" name="file" />
                    &lt;input type="button" class="button" value="Upload" id="file_upload">
                &lt;/div>
            &lt;/form>
        &lt;/div></pre>



<h2 class="wp-block-heading">CSS </h2>



<p class="wp-block-paragraph">CSS code to design the above HTML form. We just added this CSS to improve the form view. Its just optional you can skip this part.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="css" data-enlighter-theme="wpcustom" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">.container{
   margin: 0 auto;
   border: 0px solid black;
   width: 50%;
   height: 250px;
   border-radius: 3px;
   background-color: ghostwhite;
   text-align: center;
}
/* Preview */
.preview{
   width: 100px;
   height: 100px;
   border: 1px solid black;
   margin: 0 auto;
   background: white;
}

.preview img{
   display: none;
}
/* Button */
.button{
   border: 0px;
   background-color: deepskyblue;
   color: white;
   padding: 5px 15px;
   margin-left: 10px;
}</pre>



<h2 class="wp-block-heading">PHP file to upload the image</h2>



<p class="wp-block-paragraph">PHP file upload script. You can check the image type before uploading them on the server. if the image gets uploaded, it shows the path of the image otherwise if there is any problem in image upload it will show you 0.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="php" data-enlighter-theme="wpcustom" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?php

/* Getting file name */
$filename = $_FILES['file']['name'];

/* Location */
$location = "fileUpload/".$filename;
$uploadOk = 1;
$imageFileType = pathinfo($location,PATHINFO_EXTENSION);

/* Valid Extensions */
$valid_extensions = array("jpg","jpeg","png");
/* Check file extension */
if( !in_array(strtolower($imageFileType),$valid_extensions) ) {
   $uploadOk = 0;
}

if($uploadOk == 0){
   echo 0;
}else{
   /* Upload file */
   if(move_uploaded_file($_FILES['file']['tmp_name'],$location)){
      echo $location;
   }else{
      echo 0;
   }
}</pre>



<h2 class="wp-block-heading">Uploading Image and Showing Preview using jQuery AJAX</h2>



<p class="wp-block-paragraph">This script contains a jQuery which sends the file to the fileUpload.php. if it gets response 0 from  PHP file it means the file did not get upload, on other than 0 status means the file has been uploaded and then it shows the uploaded image in <strong><em>.preview img</em></strong> class.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="js" data-enlighter-theme="wpcustom" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  	 $(document).ready(function(){
                    $("#file_upload").click(function(){
                        var fd = new FormData();
                        var files = $('#file')[0].files[0];
                        fd.append('file',files);
                        $.ajax({
                            url: 'fileUpload.php',
                            type: 'post',
                            data: fd,
                            contentType: false,
                            processData: false,
                            success: function(response){
                                if(response != 0){
                                    $("#img").attr("src",response); 
                                    $(".preview img").show(); // Display image 
                                }else{
                                    alert('file not uploaded');
                                }
                            },
                        });
                    });
            });</pre>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link">Output</a></div>
</div>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="jQuery ajax image upload in PHP with preview" width="735" height="413" src="https://www.youtube.com/embed/zF7MXXaY7gk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div></figure>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link" href="https://atcodex.com/wp-content/uploads/2020/07/jQuery-ajax-image-upload-in-PHP-with-preview.zip">Download Source Code</a></div>
</div>
<p>The post <a href="https://atcodex.com/php/jquery-ajax-image-upload-in-php-with-preview/">jQuery ajax image upload in PHP with preview</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to trigger an event in input text after I stop typing/writing</title>
		<link>https://atcodex.com/how-to/triggering-callback-after-the-user-stops-typing-jquery/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Sat, 25 Jul 2020 19:37:40 +0000</pubDate>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[jQuery]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=545</guid>

					<description><![CDATA[<p>Sometimes we need to trigger a subsequent function when performing some task. In this post, we will explain to you how you can trigger callback in jQuery after the user &#8230; </p>
<p>The post <a href="https://atcodex.com/how-to/triggering-callback-after-the-user-stops-typing-jquery/">How to trigger an event in input text after I stop typing/writing</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Sometimes we need to trigger a subsequent function when performing some task. In this post, we will explain to you how you can trigger callback in jQuery after the user stops typing. </p>



<p class="wp-block-paragraph">The callback is used in many ways like we use callback function in AJAX call, autosave something, etc.  In the below code snippet, we have given a textarea. When you stop after writing something then the callback function triggered automatically and alert you the message. In application, you can perform some other activity instead of alert.</p>



<p class="wp-block-paragraph">This is a useful code that you can use to trigger a call backup function such as autosave, ajax request, spelling check, or something else as per requirements.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">//HTML
&lt;textarea id="input-box">&lt;/textarea></pre>



<h2 class="wp-block-heading">jQuery code to Trigger callback after the user stops typing.</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">var x_timer;    
$("#input-box").keyup(function (e){
    clearTimeout(x_timer);
    var user_name = $(this).val();
    x_timer = setTimeout(function(){
       // callback_function();
       console.log("user stopped");
    }, 1000);
});</pre>



<p class="wp-block-paragraph">Complete Code </p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="wpcustom" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&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>How to trigger an event in input text after I stop typing/writing&lt;/title>
&lt;/head>
&lt;body>
&lt;textarea id="input">&lt;/textarea>
&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">&lt;/script>
&lt;script>
var x_timer;    
$("#input").keyup(function (e){
    clearTimeout(x_timer);
    var user_name = $(this).val();
    x_timer = setTimeout(function(){
       // callback_function();
       console.log("user stopped");
       alert('user stopped');
    }, 1000);
});
&lt;/script>
&lt;/body>
&lt;/html></pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">You can also check  <a href="https://atcodex.com/jquery/restrict-multiple-urls-in-the-input-field-with-jquery-validation/">Restrict multiple URLs or Email id in the Input field with jQuery validation</a>.</p>
<p>The post <a href="https://atcodex.com/how-to/triggering-callback-after-the-user-stops-typing-jquery/">How to trigger an event in input text after I stop typing/writing</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to enable and disable the submit button using jQuery?</title>
		<link>https://atcodex.com/how-to/how-to-enable-and-disable-the-submit-button-using-jquery/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Sat, 25 Jul 2020 19:08:12 +0000</pubDate>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[jQuery]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=539</guid>

					<description><![CDATA[<p>In form submission, we don&#8217;t want user to click multiple times on the submit button. You may want to disable the submit button when the form is being submitted to &#8230; </p>
<p>The post <a href="https://atcodex.com/how-to/how-to-enable-and-disable-the-submit-button-using-jquery/">How to enable and disable the submit button using jQuery?</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In form submission, we don&#8217;t want user to click multiple times on the submit button. You may want to disable the submit button when the form is being submitted to the server because resubmit the same content to the server again and again, may cause script failure. </p>



<p class="wp-block-paragraph">To overcome this problem we can simply disable the submit button so the user can not click the button again until it gets released when we get a response from the server. </p>



<p class="wp-block-paragraph">In this post we will show you how you can disable the submit button after form submission.</p>



<p class="wp-block-paragraph">First add the jQuery library so that our function can work.</p>



<pre class="wp-block-code"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">&lt;/script></code></pre>



<p class="wp-block-paragraph">Use <strong>jQuery&nbsp;<em>prop()</em>&nbsp;</strong>to disable a button.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">//where #submit is id of your form submit button
$("#submit").prop( "disabled", true);</pre>



<ul class="wp-block-list"><li>Use <strong>true  </strong>&#8211; when you want to disable the button </li><li>Use <strong>false </strong>&#8211; when you want to enable the button </li></ul>



<p class="wp-block-paragraph">If user clicks on submit button, we can disable it like this :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$("#submit").click(function () {
	$(this).prop( "disabled", true);
	//$(this).prop( "disabled", false); //to enable button just set 2nd parameter false
});</pre>



<p class="wp-block-paragraph">Here is the full example</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&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>How to enable and disable the submit button using jQuery?&lt;/title>
&lt;/head>
&lt;body>
&lt;button id="submit">Submit&lt;/button>
&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">&lt;/script>
&lt;script>
$("#submit").click(function () {
	$(this).prop( "disabled", true);
});
&lt;/script>
&lt;/body>
&lt;/html></pre>



<div class="wp-block-group is-layout-flow wp-block-group-is-layout-flow"><div class="wp-block-group__inner-container"></div></div>



<p class="wp-block-paragraph">Hope it will help.</p>



<p class="wp-block-paragraph">You can also check <a href="https://atcodex.com/jquery/simple-jquery-form-validation/">Simple jQuery form validation</a>.</p>



<p class="wp-block-paragraph"></p>
<p>The post <a href="https://atcodex.com/how-to/how-to-enable-and-disable-the-submit-button-using-jquery/">How to enable and disable the submit button using jQuery?</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Restrict multiple URLs or Email id in the Input field with jQuery validation</title>
		<link>https://atcodex.com/jquery/restrict-multiple-urls-in-the-input-field-with-jquery-validation/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Sat, 25 Jul 2020 13:28:23 +0000</pubDate>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[jQuery]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=520</guid>

					<description><![CDATA[<p>Sometimes we need to restrict users from submitting more than one URL in the HTML form. In that scenario, we can use the following jQuery code. We need to use &#8230; </p>
<p>The post <a href="https://atcodex.com/jquery/restrict-multiple-urls-in-the-input-field-with-jquery-validation/">Restrict multiple URLs or Email id in the Input field with jQuery validation</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Sometimes we need to restrict users from submitting more than one URL in the HTML form.  In that scenario, we can use the following jQuery code.  We need to use <strong>RegEx expression</strong> and JavaScript&nbsp;<strong>match()</strong> function to match the pattern of  input string. When input string gets matched then it compared with <strong>allowed</strong> variable in the code.  </p>



<p class="wp-block-paragraph">You can set, how many URLs can be used in textarea. If you will set 2 then it allows only 2 URLs in the textarea.</p>



<p class="wp-block-paragraph">Create a textarea and submit button :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;textarea id="text" cols="30" rows="4">&lt;/textarea>&lt;br />
&lt;button id="submit">Submit&lt;/button></pre>



<p class="wp-block-paragraph">Add ajax library to run the jQuery code :</p>



<pre class="wp-block-code"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">&lt;/script></code></pre>



<p class="wp-block-paragraph">Add jQuery code to validate the input string.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">var allowed = 1; // how many times url can be allowed
var regex = /https?:\/\/[\-A-Za-z0-9+&amp;@#\/%?=~_|$!:,.;]*/g; //match urls
//var regex = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}\b/ig; //match emails

$('#text').on('input', function() {
	var textArea = $(this).val().match(regex); // search string
	if(textArea &amp;&amp; textArea.length > allowed){
		$('#submit').prop("disabled", true);
	}else{
		$('#submit').prop("disabled", false);
	}
});</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Here we have validated the multiple URL. you can validate the multiple email id also, for email id you can find RegEx expression in the above code, just uncomment that and you can validate the multiple Email id. </p>



<p class="wp-block-paragraph">Using different  <strong>RegEx expression</strong> you can validate the other things like a number, particular string pattern, etc.</p>



<p class="wp-block-paragraph"><strong>NOTE</strong></p>



<ul class="wp-block-list"><li><strong>&nbsp;<em>/g</em>&nbsp;</strong>at the end of regular expression? it stands for &#8220;Global search&#8221; flag. it returns multiple matched records, without this you will only get last matched record.</li></ul>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link">Output</a></div>
</div>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Restrict multiple URLs in the Input field with jQuery validation" width="735" height="413" src="https://www.youtube.com/embed/x7huDp-QnIc?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div></figure>
<p>The post <a href="https://atcodex.com/jquery/restrict-multiple-urls-in-the-input-field-with-jquery-validation/">Restrict multiple URLs or Email id in the Input field with jQuery validation</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
