There are plenty of tutorials out there like here and official jQuery Validate docs. But they're not working anymore to overwrite the required messages.
So this one does not overwrite the required message. But anyway all tutorials out there say it should work in that way:
$('#my-form').validate({
rules: {
mail: "required",
},
messages: {
mail: {
required: "Give an email in!",
},
}
});
If I do it in this way:
$('#my-form').validate({
rules: {
mail: "required",
},
messages: {
mail: "Give an email in!",
}
});
it works. And it really overwrite the usual "Field Email is required". But now I'm not able to set any other message. So this is not useful!
So how is it possible to overwrite the required text right now?
I'm using Drupal 7.51 with Clientside Validation 7.x-1.42 and jQuery 1.10.2.
Other messages are correctly owerwritten anyway
So when I take the email instead of required, it correctly owerwrites it. So it's something with the required message I would assume? What are your ideas about this:
$('#my-form').validate({
rules: {
mail: "email",
},
messages: {
mail: {
email: "Invalid email",
},
}
});
Also setting messages globally works, except on required
Works for email, but not on required:
jQuery.extend(jQuery.validator.messages, {
required: "required...",
email: "email...",
});
Possible workarounds (but no solution)
Hint: I had the issue that other forms were not working properly. But this was just an issue of setting the #required
property in PHP. After setting it to all the different user-register forms, they were working as well.