Skip to content

Instantly share code, notes, and snippets.

@acflint
Last active November 2, 2018 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acflint/9c830990d81a998c3708cd1018f9cfd0 to your computer and use it in GitHub Desktop.
Save acflint/9c830990d81a998c3708cd1018f9cfd0 to your computer and use it in GitHub Desktop.
Javascript to replace Nationbuilder form errors
<!-- add to any page in your Nationbuilder theme where there's a form and you want to update the error messages. -->
<script language="JavaScript">
$(document).ajaxComplete(function(event, request, settings) {
// this would replace any error message that contains 'Email' with 'Le courriel doit ètre remplie'
$(".form-errors ul li:contains('Email')").text('Le courriel doit ètre remplie');
// this would replace any error message that contains ‘First name' with 'Le prénom doit ètre remplie'
$(".form-errors ul li:contains('First name')").text('Le prénom doit ètre remplie');
// this would replace any error message that contains ‘Last name' with 'Le nom doit ètre remplie'
$(".form-errors ul li:contains('Last name')").text('Le nom doit ètre remplie');
// you can duplicate as many times as needed, for each error message that you want to translate.
});
</script>
@asimoesmcartor
Copy link

Nice Alex! Just seeing this now -- yes. Much improved than my hacky script haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment