-3

如何制作一个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>
4

1 回答 1

1

看看这个例子here

<?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>

现在请仔细看看它并尝试在你的代码上实现它,重要的是你理解它

于 2013-07-07T13:02:18.817 回答