I have a rails form, and the label and input-box for each field are under a div class="field". When the user enters invalid data, rails changes the class to div class="field_with_errors" for me. My question is, when this happens, how do I populate the input-box with some predefined text?
I realize this is possible with javascript, but I’m clueless on how to implement it.
You could do this on the server side by using
errors[:attribute]. You can find more info on the ruby on rails guides.