1
首先,不好意思,如果我犯了語言錯誤,這不是我的母語。如何在Rails的f.input上使用蒙版?
我正在學習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>
感謝您的幫助,如果需要任何額外的信息,就問我。
看看[jQuery Mask插件](ht tp://igorescobar.github.io/jQuery-Mask-Plugin/),這應該可以幫助你實現你所需要的。 – vee 2014-10-02 17:43:47
你也可以嘗試[maskedinput](http://digitalbush.com/projects/masked-input-plugin/)和[inputmask](https://github.com/RobinHerbots/jquery.inputmask) – IS04 2014-10-02 17:57:24
我試過[Input掩碼](https://github.com/RobinHerbots/jquery.inputmask),我不能讓它正確工作。 – inblank 2014-10-02 17:59:47