0
0

number_field_tag に設定オプション「step」を使って小数点を設定する

Posted at

概要

number_field_tag に、小数点を入力できない!とお思いの方に有用です。

対象

  • number_field_tag に小数点入力ができる設定方法を探している
  • stepの書き方 早見表を見たい方
    • step: 1
    • step: 0.1
    • step: 0.01
    • step: 0.001

基本形

number_field_tag(要素名, value値=nil, オプション={})

が number_field_tag の型です。

step
number_field_tag 'price', nil, step: 1

早見表

step: 1 を設定

step
number_field_tag 'price', nil, step: 1

満たさない場合の結果
number_field_tag_1.png

step: 0.1 を設定

step
number_field_tag 'price', nil, step: 0.1

満たさない場合の結果
number_field_tag_2.png

step: 0.01 を設定

step
number_field_tag 'price', nil, step: 0.01

満たさない場合の結果
number_field_tag_3.png

step: 0.001 を設定

step
number_field_tag 'price', nil, step: 0.001

満たさない場合の結果
number_field_tag_4.png

一言

  • 設定オプションは第三引数に設定すること!!
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0