如何驗證圖像像素? 以下是我的代碼,但只適用於圖像類型和大小。如何驗證圖像像素?
<!DOCTYPE html>
<html>
<head>
<title>Image Validation</title>
<meta charset="utf-8">
<title>jQuery validation plug-in - comment form example</title>
<script src="lib/jquery.js"></script>
<script src="js/file-validator.js" type="text/javascript" charset="utf-8"></script>
<script src="js/app.js"></script>
<link rel="stylesheet" href="css/cssval.css">
<body>
<fieldset>
<legend>Image</legend>
</p>
</li>
<li>Choose an image file:
<input type='file' class='demo' data-type='image' data-max-size='2mb' />
</li>
</fieldset>
</body> </html>
</head>
我試着去添加此但沒有運氣:document.getElementById('your_form')。onsubmit = function(){ var uploadImage = document.getElementById('upload_field').value; var img = new Image(); img.src = uploadImage; img.onload = function(){ if(this.width> 200 || this.height> 400)alert('Your image is too big,it must be less than 200x400'); } } } – 2014-12-05 06:41:07