How can I format a phone number in Rails?

I have text_field_tagwhere the user enters a phone number. I need to reformat the telephone number after a user input, for example (XXX) XXX XXXX. I am creating a java script where it will do this for me, but how can I add it to this Ruby line code?

javascript method ------> formatNumber (number)

<%= text_field_tag :mobile_number, '', :class => 'email-address' %>
+3
source share
2 answers

If you use Rails, it is easier to use the built-in # number_to_phone instead of custom Javascript.

+7
source

javascript. 1) .js.erb( ajax-) 2) , , , javascript html.erb view

0