I'm using the jquery validate plugin to validate my form. There is also server side validation and I'd like to be able to flag up the fields showing errors from the server side validation such as unique email if it's not been caught by the jquery validation.
I'm receiving a json object from my server script which has field name and then error.
I thought of using the showErrors() function but can't work out the right way to get this to work. Here's my script so far:
$.each(errors, function (key, value) {
console.log("Key:", key);
validator.showErrors({
key: value[0]
})
});
This throws an error - uncaught typeError so I assume referencing key as the field name doesn't cut it. I realise it's evaluating key as the field name rather than the value contained in key which is what I'm trying to achieve.
Thanks