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.xml 中找到任何解决方案。

请就此向我提出建议。

谢谢,巴兰

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

像这样的任何东西都适用于rails 5

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