Guest User

Untitled

a guest
Feb 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. # controller
  2.  
  3. class StaticController < ApplicationController
  4.  
  5. def compare_passwords
  6. respond_to do |type|
  7. type.js do
  8. render :update do |page|
  9. page.replace_html 'password_match', params[:password] == params[:password_confirmation] ? 'Passwords match!' : 'Passwords do not match...'
  10. end
  11. end
  12. end
  13. end
  14.  
  15. end
  16.  
  17. # view
  18.  
  19. <%= start_form_tag :action => 'register' %>
  20. <p>Password: <%= password_field_tag 'password' %></p>
  21.  
  22. <p>Confirm Password: <%= password_field_tag 'password_confirmation' %> <span id="password_match"></span></p>
  23.  
  24. <%= observe_field 'password_confirmation', {
  25. :url => { :action => 'compare_passwords' }, :frequency => 1,
  26. :with => "'password_confirmation=' + encodeURIComponent(value) + '&password=' + $F('password')" } %>
  27.  
  28. <p><%= submit_tag 'Register!' %></p>
  29. <%= end_form_tag %>
Add Comment
Please, Sign In to add comment