如何讓一個javascript函數來驗證一個數字是否在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的最小和最大數之間?'意思是 –
echo'string';在Javascript中是錯誤的。替代品是console.log('string');或者將DOM頁面元素設置爲一個值。 – Paul