【问题标题】:how to stop a user reducing an integer input to less than 1如何阻止用户将整数输入减少到小于 1
【发布时间】:2021-08-11 15:36:19
【问题描述】:

我有一个简单的整数输入形式,当单击输入中的箭头(右侧)时,我不想阻止用户将数量减少到 1 以下。

如果没有 javascript,这可能吗?我能找到的唯一信息是将min 属性添加到输入中,但这不起作用。

<%= f.input :quantity, as: :integer %>

【问题讨论】:

    标签: ruby-on-rails input simple-form


    【解决方案1】:

    关注this 应该可以帮助您。

    在你的情况下,尝试:

    <%= f.input :quantity, as: :integer, input_html: { min: '0' } %>
    

    更多阅读:https://github.com/heartcombo/simple_form

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-03
      • 2017-01-28
      • 2017-01-23
      • 1970-01-01
      • 2019-09-19
      相关资源
      最近更新 更多