jQuery remote validation with server generated error message
I am using the Validation jQuery plugin to do some validation. I have a service which returns "true" and "false" right now and everything is great.
However, the error message I am using is "That name is already taken."
I want the error message to be "That name is already <a href="/item?id=543"> taken</a>."
where that item id is something returned from the server. But I can't figure out how to return anything from the server other than a single true or false and still have the validation work.
I know I can do "The name xxx is taken" using JQuery.Format("The name {0} is taken") but I really want to give a hyperlink to the existing item, and I don't want to have to chan开发者_如何学运维ge the item pages to accept a name instead of an id.
The validation plugin handles this already, but the call type is "json"
, so you need to make sure the string (error message) is passed in quotes, like this:
"Error Message"
The plugin will use this as the displayed error message, handy eh? :)
精彩评论