-1

I've got a simple sign up form including this line

    <%= f.label :password, 'Password:' %>
    <%= f.password_field :password, required: true %>

now if someone tries to sign up and leaves the password blank, there's an error flashed in the form. Where can I define what this error actually says?

Krawalla
  • 198
  • 1
  • 13

1 Answers1

1

You can set custom message for required attribute using setCustomValidity
But to do that you need to do some js coding.
So, I think you can have a workaround by doing this in rails

<%= f.password_field :password, onchange: "if ($('#password').val().length == 0) { alert('Password field is blank(custom text)!'); }" %>

I have not tested this but I think this will work

Community
  • 1
  • 1
Sajin
  • 1,608
  • 1
  • 14
  • 18