observe_form, rjs for form validate and a lot of mistakes!

First, thanks for reading this post!

Today i’m trying to implement a real-time form validator.

I have a model (user) within:

   t.column :email, :string
   t.column :name, :string
   t.column :surname, :string
   t.column :nickname, :string
   t.column :gender, :integer
   t.column :site, :string
   t.column :birthday, :datetime
   t.column :culinary, :string
   t.column :avatar, :string
   t.column :description, :string
   t.column :password, :string
   t.column :active, :boolean, :default => false

the validation rules:

validates_uniqueness_of :email, :nickname validates_length_of :password, :within => 4…10 validates_length_of :email, :maximum => 50 validates_presence_of :name, :surname, :email, :password, :nickname validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i # ( needs a improve )

and the controller code:

def signup @title = “site_name: signup” unless logged_in? @user = User.new(params[:user]) if @user.valid? #@user.save
flash[:notice] = “user registered” end else redirect_to :controller => “site_name”, :action => “index” end end

And i wan’t to use XML (RJS), to validate in real-time what the user type in fields. If what was type can’t be allowed (see validate rules) a message or a red border indicates a error. I try several times, read a lot of articles in google and see 4 railscasts.

Can anyone help me?

Obs.: sorry for my poor english.

and the controller code:

  def signup      @title = "site_name: signup"      unless logged_in?         @user = User.new(params[:user])            if @user.valid? #@user.save               flash[:notice] = "user registered"            end      else         redirect_to :controller => "site_name", :action => "index"      end   end

And i wan't to use XML (RJS), to validate in real-time what the user
type in fields. If what was type can't be allowed (see validate
rules) a message or a red border indicates a error. I try several
times, read a lot of articles in google and see 4 railscasts.

I have a vague feeling there's already something like this. First off,
xml and rjs have nothing to do with each other. In a nutshell if you use observe_form, an ajax request will submit the
form whenever the fields change. In you controller you can cal
User.new on those submitted parameter. In your rjs you can render the
error messages (using error_messages_for or rolling your own) and
insert them into a div (page.insert_html etc...)

Fred