Dear all Sorry for dummy question. How can I convert a text input in form to upper case letter in view? Can I call the javascript function toUpperCase() in text_field_tag?? <%= text_field_tag(:sometext, nil, :size => 14) %> I know I can achieve this using params[:sometext].upcase in controller, but I want to do this in view. Any ideas? Many thanks Valentino -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Charanya Nagarajan
2009-Apr-17 11:59 UTC
Re: how to call javascript function in text_field_tag
<script type="text/javascript"> function changecase() { (document.getElementById("sometext")).value=document.getElementById("sometext").value).toUpperCase(); } </script> <%= text_field_tag(:sometext, nil, :size => 14 , :onchange => "changecase();") %> When u enter the text in the textbox and when the focus goes out of the textbox the text changes to uppercase. Hope this might help. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Schalk Neethling
2009-Apr-17 12:11 UTC
Re: how to call javascript function in text_field_tag
Hi Charanya, Or try using unobtrusive JavaScript by giving the field a unique id and then hooking up the action to that id. With jQuery it is very simple. To get the field just use: $(''#uniqueid'') and then you can chain any function to the element. HTH, Schalk Charanya Nagarajan wrote:> <script type="text/javascript"> > function changecase() > { > (document.getElementById("sometext")).value=document.getElementById("sometext").value).toUpperCase(); > } > > > </script> > > <%= text_field_tag(:sometext, nil, :size => 14 , :onchange => > "changecase();") %> > > When u enter the text in the textbox and when the focus goes out of the > textbox the text changes to uppercase. > > Hope this might help.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---