---
title: "How to implement image size validation in jquery?"  
description: "How to implement image size validation in jquery?"  
author: "Anonymous User"  
published: 2018-03-19  
updated: 2018-03-19  
canonical: https://www.mindstick.com/forum/34441/how-to-implement-image-size-validation-in-jquery  
category: "c#"  
tags: ["jquery"]  
reading_time: 1 minute  

---

# How to implement image size validation in jquery?

Hi,

I want to [apply](https://www.mindstick.com/articles/13148/discover-to-apply-make-up-like-a-professional-supermodel) [image](https://www.mindstick.com/articles/23551/an-investigate-distinctive-seafood-restaurant-for-your-image-stamp-character) [size](https://www.mindstick.com/forum/159799/how-can-you-manage-the-size-of-mdf-and-ldf-files) [validation](https://www.mindstick.com/articles/12234/validation-using-data-annotation-using-entity-framework) on image [upload](https://www.mindstick.com/forum/12860/how-to-upload-file-asynchronously-using-generic-handler) with the help of jquery.

Here is my [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):

```
<div class="col-md-6">        <label for="imageUpload">Upload Your Image</label>        <input name="ContentImage" id="ContentImage" type='file' onchange="readURL(this);" style="background: none" /></div>
```

Please give me some solution to achieve this task.

## Replies

### Reply by Hemant Patel

Hi Indrajit,

You can be achieved your task by following these steps:

**Step 1.** First of all, create a method on button submit.

**Step 2.** Now write following lines of code in your jquery method.

```
if (typeof ($("#ContentImage")[0].files) != "undefined" && ContentImage != '') {        var size = parseFloat($("#ContentImage")[0].files[0].size / 1024).toFixed(2);        if (size > 500) {            alert("Image Size Exceeded !!!");            return false;        }    }
```

I hope it's informative!!!


---

Original Source: https://www.mindstick.com/forum/34441/how-to-implement-image-size-validation-in-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
