gerky
gerky

Reputation: 6415

JQuery Validate, How to Customize Error Message?

I am trying to customize the error messages shown by Jquery Validate, It is currently showing "Email is already taken", but what I want is for example the user entered user@yahoo.com, and it's already taken, I want to see "user@yahoo.com" is already taken. My field ID is user_email, I tried using $('#user_email).val() in the example but it's not showing. I have the fallowing code.
Thanks in advance!

remote: {
  url: user_email_availability_url,
  beforeSend: function() {
  },
  complete: function() {
  }
}

messages: {
  "user[email]": {
  remote:  $('#user_email').val() + "is already taken",
  email: 'Invalid email address'
},

Upvotes: 1

Views: 196

Answers (2)

J. Ed
J. Ed

Reputation: 6752

perhaps you should try making that message a function (I believe that's possible):

remote: function(value) {
 return value + " is already taken"
 }

Upvotes: 1

Ruslan Polutsygan
Ruslan Polutsygan

Reputation: 4461

In the plugin file you can find line(about 230) where all error messages are setuped.

I hope it will be helpfull

Upvotes: 0

Related Questions