当我按ok
按钮时,为什么不检查return false;
?
在这种情况下填充小于500x500px的图片网址https://pbs.twimg.com/profile_images/839721704163155970/LI_TRk1z_400x400.jpg
(400x400像素)为什么不return false;
我该怎么办?
test1.php
<form class="form" method="post" action="" ENCTYPE = "multipart/form-data" onsubmit="return checkform(this);" >
<input type="text" id="image_data" name="image_data" value="https://pbs.twimg.com/profile_images/839721704163155970/LI_TRk1z_400x400.jpg">
<input type="submit" name="submit" value="OK">
</form>
<form id="image_fid">
<input type="text" name="image_data_url" id="image_data_url"/>
<input type="text" name="image_data_dimension_width" id="image_data_dimension_width"/>
<input type="text" name="image_data_dimension_height" id="image_data_dimension_height"/>
</form>
<span id="mySpan_image_fid"></span>
<script language="JavaScript" type="text/javascript">
function checkform ( form )
{
var image_data_val = document.getElementById("image_data").value;
document.getElementById("image_data_dimension_width").value = "";
document.getElementById("image_data_dimension_height").value = "";
$.ajax
(
{
url: 'test2.php',
type: 'POST',
data: $('#image_fid').serialize(),
cache: false,
success: function (data) {
$('#mySpan_image_fid').html(data);
get_image_data_width_height();
}
}
)
}
function get_image_data_width_height(){
var image_data_dimension_width_val = document.getElementById("image_data_dimension_width").value;
var image_data_dimension_height_val = document.getElementById("image_data_dimension_height").value;
if((image_data_dimension_width_val > '500') && (image_data_dimension_height_val > '500'))
{
return true;
}
else
{
return false;
}
}
</script>
test2.php
<?PHP
session_start();
include("connect.php");
$image_data_url = mysqli_real_escape_string($db_mysqli,$_POST['image_data_url']);
$image_data_dimension = getimagesize($image_data_url);
$image_data_dimension_width = $image_data_dimension[0];
$image_data_dimension_height = $image_data_dimension[1];
?>
<script>
document.getElementById("image_data_dimension_width").value = "<?PHP echo $image_data_dimension_width; ?>";
document.getElementById("image_data_dimension_height").value = "<?PHP echo $image_data_dimension_height; ?>";
</script>