11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'app/helpers/application_helper.rb', line 11
def password_fields(form, options={})
base_options = {
:password_field => :password,
:confirmation_field => :password_confirmation,
:password_label => t(:password),
:confirmation_label => t(:password_confirmation).capitalize,
:label_class => '',
:input_class => '',
:field_class => 'grid_5',
}
opts = base_options.merge(options)
password_field = opts[:password_field]
confirmation_field = opts[:confirmation_field]
fields = ''
fields += "<div class='#{opts[:field_class]} password_field'>"
fields += "<div class='#{opts[:label_class]} password_field'>"
fields += form.label(password_field, opts[:password_label])
fields += '</div>'
fields += "<div class='#{opts[:input_class]} password_field'>"
fields += form.password_field(password_field)
fields += '</div>'
fields += '</div>'
fields += "<div class='#{opts[:field_class]} password_field'>"
fields += "<div class='#{opts[:label_class]} password_field'>"
fields += form.label(confirmation_field, opts[:confirmation_label])
fields += "</div>"
fields += "<div class='#{opts[:input_class]} password_field'>"
fields += form.password_field(confirmation_field)
fields += "</div>"
fields += "</div>"
fields += "<script type=\"text/javascript\">
$('#user_password').bind('keyup', function(){
if ($(this).val().length > 5){
$(this).addClass('right_password');
$(this).removeClass('wrong_password');
} else{
$(this).addClass('wrong_password');
$(this).removeClass('right_password');
}
});
$('#user_password_confirmation').bind('keyup', function() {
if($(this).val() == $('#user_password').val()){
$(this).addClass('right_password');
$(this).removeClass('wrong_password');
} else{
$(this).addClass('wrong_password');
$(this).removeClass('right_password');
}
});
</script>"
fields
end
|