2

私はアプリケーションで単純なフォームを使用しています。インラインjsを使用してフィールド名を設定し、ユーザーがフィールドをクリックして次のように変更すると設定を解除します。

input type="text" class="ftext" value="First Name" onclick="if(this.value=='First Name') this.value='';" onblur="if(this.value=='') this.value='First Name'"

単純なフォームinptでこれを実行しようとしています<%= f.input :password, :required => true, :class => "ftext" %>が、Webで解決策を見つけることができません。

これについて私に提案してください。

ありがとう、バラン

4

2 に答える 2

2

以下に示すように、「input_html」オプションを使用してこれを行うことができます。

<%= f.input :email, :required => true, :autofocus => true, :input_html => { :onclick => "customFunction()", :class => "stext", :style => "padding-left:93px;width:170px;" } %>
于 2012-08-27T14:07:44.313 に答える
1

このようなものはすべてRails5で機能します

<%= f.input :email, :required => true, :autofocus => true, onclick: "yourFunction()" %>
于 2018-04-26T05:28:02.630 に答える