如何在Rails上的f.input上使用掩码?

时间:2014-10-02 17:33:37

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

首先,对不起,如果我犯了语言错误,这不是我的母语。

我正在学习RoR,我正在构建一个CRUD来注册很多计算机的信息,我正在使用Simple Form来生成表单。我的问题是,如何在f.input元素中使用掩码?

就像当用户插入Ip地址时,他会在文本字段中得到类似---. ---。--- .---的内容。

如果有帮助,这是表格的这一部分:

<div class="field">
    <%= f.input :mac_adress, label: 'Type the machine\'s MAC ADRESS: ', placeholder: 'XX:XX:XX:XX:XX:XX' %>
</div>
<div class="field"> 
    <%= f.input :patrimony, label: 'What is the patrimony number? ', placeholder: 'XXXXXX' %>
</div>
<div class="field"> 
    <%= f.input :ip, label: 'Inform the IP adress: ', placeholder: 'XXX.XXX.XXX.XXX' %>
</div>
<div class="field"> 
    <%= f.label :lab_id %>: 
    <%= f.text_field :lab_id, :value => @machine.lab.name, :hidden => true %>
</div>
<div class="actions">
    <%= f.button :submit %>
</div>

感谢您的帮助,如果需要任何其他信息,请询问。

1 个答案:

答案 0 :(得分:2)

我是:

      x2=melt(x1)
      ggplot(x2,aes(x = value)) + 
      facet_wrap(~variable,scales = "free_x") + 
      geom_histogram(aes=(density))
      +title(sub = s, line = 5.5) 
      s<-summary(x1)

此致:

<%= f.text_field :phone, class: "form-control", :required => true, :data => {:mask=> '999-999-9999'} %>

在你的application.js

中添加这个js
  

jasny / jasny-bootstrap.min.js