473,473 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How i Validation Width and height multiple input image before save using jquey

2 New Member
i have two input every input upload one image , and i write script to validation width and height for one input only and i don't know i use this script to validation two input.

this is html code:-

<input class="form-control valid" data-val="true" data-val-required="This field is required" id="File1" name="File_ar" type="file" value="">

<input class="form-control valid" data-val="true" data-val-required="This field is required" id="File2" name="File_ar" type="file" value="">

<input type="submit" name="" value="Save" ,="" class="btn btn-primary col-md-2">


and this is script i write it:-

Expand|Select|Wrap|Line Numbers
  1. $(document).ready(function () {
  2.             $("form").submit(function (e) {
  3.                 var form = this;
  4.                 e.preventDefault(); //Stop the submit for now
  5.                 //Replace with your selector to find the file input in your form
  6.                 var fileInput = $(this).find("File_ar")[0],
  7.                     file = fileInput.files && fileInput.files[0];
  8.  
  9.                 console.log(file)
  10.                 if (file) {
  11.                     var img = new Image();
  12.  
  13.                     img.src = window.URL.createObjectURL(file);
  14.  
  15.                     img.onload = function () {
  16.                         var width = img.naturalWidth,
  17.                             height = img.naturalHeight;
  18.  
  19.                         window.URL.revokeObjectURL(img.src);
  20.  
  21.                         if (width == 1024 && height == 358) {
  22.                            form.submit(); 
  23.                         }
  24.                         else
  25.                         {
  26.                             alert('image must be 1024*358');
  27.                         }
  28.                     };
  29.                 }
  30.             });
  31.         });
  32.  
Jun 18 '17 #1
0 1419

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Premshree Pillai | last post by:
Hello, Is there a Py module available using which I can find the width and height of any image format? -Premshree ===== -Premshree http://www.qiksearch.com/]
5
by: Sharlet | last post by:
I am having a problem here. I have an ASP page which displays different images according to the querystring and the images are all of different sizes. However, in some browsers the image...
5
by: homecurr | last post by:
I am writing a tool to generate html and have a problem with the <img> tag. The tool generates something like "<img src="...">". At the time the html is generated, the tool does not know the actual...
10
by: Imran | last post by:
Hi, I am attempting to create a CSS-driven website, in that I want to be able to control the display/content from the CSS file. I do not want to use tables. On a page, I have a background...
2
by: erikv | last post by:
I'm having a hard time figuring out how to get the width of an image I replace using the following code: document.getElementById("sizeImg").src="http://www.example.com/image.jpg"; After this...
3
by: Nathan Sokalski | last post by:
I need to get the width and height of a GIF image through code. I need this info so that I can set the width and height properties of Image and ImageButton objects....
1
by: Nathan Sokalski | last post by:
I am using the ImageUrl property of the Hyperlink control to create a graphical Hyperlink. However, I want to change the size of the image I am using, but the generated HTML places the width/height...
2
by: Corobori | last post by:
I am getting an error message "Description: Value cannot be null. Parameter name: encoder" when performing this instruction: frmPicView.pic.Image.Save(ms, frmPicView.pic.Image.RawFormat) Here is...
10
by: News | last post by:
I am trying to be able to manipulate the width and height of an <img> but do not seem to be able. "Yes", I know the JavaScript will "not" manip anything, which is ok. I simply do not know how to...
4
by: ramkumarm | last post by:
how can i user control image save using windows form
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.