Hi guys i am trying to validate a field in a form. I dont want that
field to contain a certain string. Lets say if a user types : “i want to
kill you” he gets a message : Change the message! How can i do that?
you can to that using a js, putting into application.js, calling the
function on the change focus
Em 13/07/2011, s 22:45, Demon M. escreveu:
Leoncio C. wrote in post #1010607:
you can to that using a js, putting into application.js, calling the
function on the change focus
Em 13/07/2011, s 22:45, Demon M. escreveu:
how can i call the function on the change focus? on(change)…?
can i do that inside the controller without a js?
maybe with :onchange works fine, wellabout that validation inside
controlleris not a best practice, the better way is into model, using a
method validates_each, this method will validate any condition with the
respective field, any doubt, please just talk
i hope it help dude
Em 13/07/2011, s 22:59, Demon M. escreveu:
Thank you Leoncio. I am going to do the validates_each inside the model.
But how can i pass the string as a parameter? basically this what i want
to do
validates_each :field.value, if field.value.eql?(bla bla bla) :message
=> “Please write smth that makes sense.”
How can i do that?
solved with a new method and a validate :method