Need to copy the Custom error message text from a span where text is coming from CMS. It is basically a need to show a custom localized error message.
Code works when you submit the form but as soon as you click outside, the default message replace the custom one.
HTML
<form name="form-core" id="form-core" method="post" action="" role="search" novalidate="novalidate">
<label for="keywords">Hello</label>
<input type="text" id="keyword" name="keyword" class="required" />
<span class="error-message-required">Ce champ est obligatoire</span>
<input type="submit" /><input class="cancel" type="submit" value="Reset" />
</form>
JS
$('#form-core').validate({
debug: false,
onfocusout: function (element) { jQuery(element).valid() },
errorElement: "div",
errorPlacement: function (error, element) {
jQuery('div[for=' + error.attr('for') + ']').remove();
error.text($(element).next('.error-message-required').text());
error.insertBefore(element);
}
});