validation-Urgent

I have written a validation in user model like
validates_format_of :password,
:with => /^(?=.\d)(?=.([a-z]|[A-Z])){6,20}$/,
:message => “Password wrong”
and also
validates_presence_of :name
and to get the message write the code <%= error_messages_for :user %>

from where the page is called but does not work.

Again when I write the code for validation in another model, then it
works.
Is there any reason why it does not work and how I get the bug ?
Please reply