JavaScript based form-validation should always start with the submit event: When a user presses enter inside one form field, the form is submitted without triggering your onclick event.
In your case it should be possible to use JSF's built-in localization features. You'd have to somehow render that message into your JavaScript when rendering the view.

