I am trying to validate a phone number when it is update. The way that it is updated is through an auto_complete__text_field and what I tried is to have: validates_format_of :h_phone, :with => /\(?[0-9]{3}\)?-[0-9]{3}-[0- 9]{4}/, :message => "- Phone numbers must be in xxx-xxx-xxxx format.", :on => :update in my model, but I think that an update using a auto_complete_text_field isn''t done via an update? I tried putting that same code in my controller but validate_format_of is part of the ActiveBase class. I guess my question is how do I validate using an auto_complete_text_field or is their another way to accomplish the same thing just in a differnt way. Thx, -S -- 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 -~----------~----~----~----~------~----~------~--~---
Shandy Nantz wrote:> I am trying to validate a phone number when it is update. The way that > it is updated is through an auto_complete__text_field and what I tried > is to have:Sorry, I''m using an in_place_editor_field not an auto_complete - had to many things going on at once. Thanks again, -S -- 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 -~----------~----~----~----~------~----~------~--~---
you can use in_place_edit instead of in_place_edit_field.... using in_place_edit you can customize the validation..something like this first thing is create a span of id="attr_name" next <%= in_place_edit "attr_name", {:url => url_for(:action=> "provide action" , :id => "optional id parameter") , :script=>true } %> remember the script => true says that u can now use the rjs methods in ur action....then in your action when you update the attribute by saying attribute.save check whether there attr.new_record exist.. if it does then throw an error message using errors.on. Dont forget to replace the new value which is in params[:value] with the span id attr_name using page.replace_html "attr_name", params[:value] I think that should work. On Mar 17, 7:59 pm, Shandy Nantz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Shandy Nantz wrote: > > I am trying to validate a phone number when it is update. The way that > > it is updated is through an auto_complete__text_field and what I tried > > is to have: > > Sorry, I''m using an in_place_editor_field not an auto_complete - had to > many things going on at once. Thanks again, > > -S > > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---