dscojuxf69080 2016-09-17 07:35
浏览 16
已采纳

如何输入除了0.0到5.0之外

I am new in javascript and don't know what to in this case please provide me solution

<input type="text" name="technical" maxlength="3" id="numa" onKeyUp="this.value = minmax(this.value, 0, 5)" class="input-text persent managementskill" value="<?=set_value('technical',$this->input->post('technical'))?>" />

<script type="text/javascript">
function minmax(value, min, max) 
{

    if(parseInt(value) < min || isNaN(value)) 
        return 0; 
    else if(parseInt(value) > max) 
        return 5; 
    else return value;

}
</script>

This is my code is working fine for the first entry of input it will not except after 5 but I want if we enter 5.1 then it automatically converts that num to 5.0 want this to except only 0.0 to 5.0 what to do in my function please help

  • 写回答

3条回答 默认 最新

  • douce1368 2016-09-17 07:42
    关注

    in simple way you can just return '5.0'; just try it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块