Rails custom client side validation message -


i'm using rails form client side validations. how can customize error message, current says:

"value must equal or greater ... "

here form field:

<%= f.number_field :age, placeholder:"age", class:"form-control", required: true, max:90, min:17, message: 'foo' %> 

html5 api has way set custom error validation message. below example:

example:

<form>   <label for="mail">i provide me e-mail</label>   <input type="email" id="mail" name="mail">   <button>submit</button> </form> 

and adding js:

var email = document.getelementbyid("mail");  email.addeventlistener("keyup", function (event) {   if (email.validity.typemismatch) {     email.setcustomvalidity("i expect e-mail, darling!");   } else {     email.setcustomvalidity("");   } }); 

documentation of setcustomvalidity().


Comments