Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # controller
- class StaticController < ApplicationController
- def compare_passwords
- respond_to do |type|
- type.js do
- render :update do |page|
- page.replace_html 'password_match', params[:password] == params[:password_confirmation] ? 'Passwords match!' : 'Passwords do not match...'
- end
- end
- end
- end
- end
- # view
- <%= start_form_tag :action => 'register' %>
- <p>Password: <%= password_field_tag 'password' %></p>
- <p>Confirm Password: <%= password_field_tag 'password_confirmation' %> <span id="password_match"></span></p>
- <%= observe_field 'password_confirmation', {
- :url => { :action => 'compare_passwords' }, :frequency => 1,
- :with => "'password_confirmation=' + encodeURIComponent(value) + '&password=' + $F('password')" } %>
- <p><%= submit_tag 'Register!' %></p>
- <%= end_form_tag %>
Add Comment
Please, Sign In to add comment