Does the html5 "pattern" attribute work in every browser?

Is html5 a template attribute to work in every browser or not? If it doesn’t work, what technique should I use to work in every browser?

+6
source share
1 answer

No, it is not. Although you can use JavaScript to get the attribute and test it that way.

if ( ! input.hasOwnProperty('pattern') && ~input.value.search(input.pattern)) { // Valid input field for browsers which don't support `pattern` attribute. } 

jsFiddle .

+9
source

Source: https://habr.com/ru/post/908298/


All Articles