Class: AlFloat
Overview
浮動小数点入力ウィジェット
Instance Method Summary (collapse)
-
- (Boolean) validate
(AlFloat) バリデート.
Methods inherited from AlNumber
#initialize, #make_tag, #set_value
Methods inherited from AlWidget
#initialize, #make_value, #set_attr, #set_value
Constructor Details
This class inherits a constructor from AlNumber
Instance Method Details
- (Boolean) validate
(AlFloat) バリデート
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/al_form/extend.rb', line 112 def validate() @message = "" if @value == "" || @value == nil if @required @message = "#{@label}を入力してください。" return false end @value = nil return true end if /^[\s]*[+-]?[\d]+(\.[\d]+)?([eE][+-]?[\d]+)?$/ !~ @value.to_s @message = "#{@label}を正しく入力してください。" return false end v = @value.to_f if @max && v > @max @message = "#{@label}は、#{@max}以下を入力してください。" return false end if @min && v < @min @message = "#{@label}は、#{@min}以上を入力してください。" return false end @value = v return true end |