Tuesday 9 August 2016

JAVASCRIPT IMAGE HIght Width validation

<input type='file' id='frontPageImage' name='frontPageImage'> 
 
<script> 
 $("#frontPageImage").live('change',function (e) { 
  var file, img; 
  if((file = this.files[0])) { 
    img = new Image(); 
    img.onload = function () { 
    if((this.width<499 || this.width > 599) && (this.height < 599 || this.height > 699)){
 
      alert("Front page image width in-between 500px 
            to 600px and height in-between 600px to 700px."); 
  
      $("#frontPageImage").val(''); 
 
 
 
      } 
 
      var isImage = validateImageExtention(this); 
      if(!isImage){ 
        alert("Select a image.");
        $("#frontPageImage").val(''); 
        } 
      }; 
 
  img.src = _URL.createObjectURL(file); 
 }});

</script>

No comments:

Post a Comment