dongmao7195 2013-07-07 12:48
浏览 28

javascript函数从php验证一个数字? [关闭]

how to make a javascript function to validate a number whether its in between the minimum and maximum numbers in 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>
  • 写回答

1条回答 默认 最新

  • duanrang2627 2013-07-07 13:02
    关注

    have a look on this example 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>
    

    now please have a close look on it and try to implement it on your code, the important thing is that you understand it

    评论

报告相同问题?

悬赏问题

  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题