I'm trying to validate two input boxes and display a custom error message using HTML5 browser validation.
- First input should be at least 3 characters, no custom error.
- Second input should be at least 4 characters, with custom error.
The validation doesn't seem to work with my second input, I'm always prompted with my custom error message. When I remove the oninvalid it works.
Where am I going wrong?
My HTML is below;
<form>
<input type="text" placeholder="min 3" pattern=".{3,}">
<input type="text" placeholder="min 4" oninvalid="this.setCustomValidity('Must be 4 Characters')" pattern=".{4,}">
<input type="submit" value="Check"></input>
</form>
I'm sure it's something obvious.. any help is appreciated.
Here's a fiddle.