I want to override the error messages by e.g. Firefox for my HTML5 form with my own personal message. But doing this causes the input field I am applying it to to not allow the form to submit. It's as if you haven't filled in the input field and the error message keeps appearing instead.
HTML part
<label for="name">Name</label>
<input id="name" name="name" placeholder="Enter Your Name" required="" type="text">
Javascript (IIFE)
var change_text = function(){
var name = document.getElementById("name");
if (!name.checkValidity()) {
name.setCustomValidity("Please enter your full name");
name.reportValidity();
}
else {
name.setCustomValidity("");
}
}();
This does change the message to my bespoke message, but it won't allow the form to submit. Interestingly, if i change my message to an empty sting, it does work (but obviously the error message doesn't show.