javascript函数来验证php中的数字


javascript function to validate a number from php?

如何制作一个javascript函数来验证一个数字,无论它是否在php中的最小和最大数字之间?

$dbosminsalary
$dbosmaxsalary
$dblastdate
<form action='workaction.php' method='post'>
<input type='number' id='amntpreferred' name='amntpreferred' class='required input_field' placeholder='Enter bid value' oninput='numberBetween();' required/> 
<script>
 function numberBetween(amntpreferred, $dbosmaxsalary, $dbosminsalary) 
 {
    if(amntpreferred <= $dbosminsalary) 
          return false;
    else if(amntpreferred >= $dbosmaxsalary)  
          return false;
    else
          return true;
 }
 if (numberBetween(amntpreferred,$dbosmaxsalary,$dbosminsalary)) 
 {
    echo 'The value is in the range!';
 } 
 else 
 {
    echo 'The value is outside the range!';
 }
</script>

在这里看看这个例子

<?php
$min = 1;
$max = 10;
?>
<script>
    function inRange(x) {
        if((x >= <?php echo $min; ?>) && (x <= <?php echo $max; ?>))
            return true;
        return false;
    }
    if(inRange(77))
        alert("it's ok");
    else
        alert("it's not ok");
</script>

现在请仔细研究一下,并尝试在代码中实现它,重要的是你要理解它