I wrote validation for checking image dimensions in jquery(not written by me,copied from stackoverflow).whenever I upload current image,then it goes to else block but not submitted. The script is working fine.But not submitting the form.Earlier I submitted the form without image validation then form submitted successfully.Whenever I wrote validation,Form is not submitted. In form tag,I return the value of submitfunction() on submit event. Here is the code: Here is the script code:
var _URL = window.URL || window.webkitURL;
function submitproject(){
var file, img;
if ((file = $('#picture')[0].files[0])) {
img = new Image();
img.onload = function() {
if(this.width!=572 && this.height!=379){
alert("Please select appropriate picture.(only 572X379 is allowed)");
return false;
}
else
{
return true;*//to submit the form on correct image dimensions*
}
};
img.onerror = function() {
alert( "not a valid file: " + file.type);
};
img.src = _URL.createObjectURL(file);
}
}
Please help me out.Thanks in advance.