In JS, I can run:
/[a-z]/.test('foo');
Which returns true
, as a single lowercase character appears anywhere inside the string.
However:
<input pattern="[a-z]" value="foo" required />
and
console.log(document.querySelector('input').checkValidity())
Returns false
.
Why does HTML5 checkValidity return different results from JavaScript regexp.test() ?