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,
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,
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.