开发者

Rails form errors - validation

开发者 https://www.devze.com 2023-03-14 12:24 出处:网络
I\'d like to be able to highlight fields that don\'t pass validation.开发者_高级运维I\'m using simple_form, and the error messages it displays just don\'t look good to me.I\'m listing the errors above

I'd like to be able to highlight fields that don't pass validation. 开发者_高级运维I'm using simple_form, and the error messages it displays just don't look good to me. I'm listing the errors above the form & I'd like to highlight (change the color of) the fields that contain invalid values. Is there an easy way of doing this?


yes it's very easy, you will likely find that the field with errors will have a class of ".field_with_errors" or something similar applied to it

just style all inputs that fall within that class to have 2px solid red border

i.e.

// style.sass
.field_with_errors
  input
    border: 2px solid red


You could also take a look at client-side-validations. You can style and display errors inline, and it supports simple_form.

0

精彩评论

暂无评论...
验证码 换一张
取 消