I have an HTML form in my Rails view
<form id="download_form" action="download">
Username: <input type="text" name="username"> <br/>
<input type="submit" id="submit_download_form" value="Submit">
</form>
In Rails controller, if the length of username is greater than 10, I’d like the controller to return to the same page, and notice the user via <p id="notice"><%= notice %></p> that the length can’t be more than 10. How can I do it?
By the way, username is not an attribute in any model. It’s just a field in this form.
You can get the length of
usernameby methodlength:Then in your view you can use
@notice: