weare138
weare138

Reputation: 1

I can not change the error message jquery validation plagin

I want to change the error message, and that it does not work

  $('form').validate();
  messages: {
    "form[name]": "test",
  }
});

how fix?

I think the problem was not in the script only, but also in html.vot just can not understand what I'm doing wrong, it is necessary that the form "name" would pass validation.

this my html

<div class="form-group col-sm-12">
        <%= f.label "Название" %>

        <%= f.text_field :name, class: "form-control", required: :require  %>
      </div>

Upvotes: 0

Views: 337

Answers (2)

Allan W Smith
Allan W Smith

Reputation: 756

Messages is a parameter of validate therefore your syntax is wrong.

Try:

  $('form').validate({
    messages: {
      "form[name]": "test"
    }
  });

Further reading: http://jqueryvalidation.org/validate/

Upvotes: 0

Arun P Johny
Arun P Johny

Reputation: 388316

You have syntax errors in the script, also the name used is wrong so

$('form').validate({
    messages: {
        "event[name]": {
            required: "test"
        }
    }
});

Demo: Fiddle

Upvotes: 1

Related Questions