I am uploading image and validating that if uploaded image is greater than 500x500 then generate an error. I am using following code to know the dimension.
rules: {
            profile_pic:{accept: "png|jpe?g",imagedim:true}
}
$.validator.addMethod('imagedim', function(value, element, param) { 
  var _URL = window.URL;
        var  img;
        if ((element = this.files[0])) {
            img = new Image();
            img.onload = function () {
                console.log("Width:" + this.width + "   Height: " + this.height);//this will give you image width and height and you can easily validate here....
                return this.width >= param
            };
            img.src = _URL.createObjectURL(element);
        }
});
But this its not returning me uploaded image height width.Every time its submitting form event if I added return false;
Please help
 
     
     
    