i need to check the value before submit  

so i tried the two method to do so but the same problem  

the problem is that user need to click once again after check is true  

i tried with chrome , firefox and IE and the same problem always  

here index.php

```
<!DOCTYPE html>
<html>
<head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script>
        submitnow=false;
        $(document).ready(function(){
            $("form#test").submit(function(e){
                //e.preventDefault(); //i test this way (here and line 17) with same problem line
                if(submitnow==false){
                        num=$("#num").val();
                        $.post("check.php",{num:num},function(result){
                            if(result=="true"){
                                alert("check return true");
                                submitnow=true;
                                $("form#test").submit();
                                //$("form#test").unbind('submit').submit();
                            }else{
                                alert("check return false");
                            }
                        });
                }
                if(!submitnow)
                    return false;
                else
                    alert("submitnow is true");
            });
        });
    </script>
<body>
    <form action="" method="POST" id="test" >
        <label for="num" >Num</label>
        <input id="num" name="num" type="text"  value="1" required/>
        </br>
        <input id="submit" type="submit" name="submit"/>
    </form>
<?php
echo (isset($_POST['submit']))?'submit done':'';
?>
</body>
</html>

```

and here check.php

```
<?php
echo ($_POST['num']==1)?'true':'false';
?>

```