Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I add the pattern attribute to textarea?

Tags:

html

I know that the textarea doesn't support the functionality of pattern, however if I set the pattern variable in html, its still present in the browser.

So I have to execute the pattern verification in js anyways, but is it OK for me to store the pattern in the pattern attribute? As opposed to data-pattern or something, for consistency with the input elements?

like image 419
user81993 Avatar asked Jan 31 '26 11:01

user81993


1 Answers

You should use data-* attributes for extra attributes and since textarea tag does not support the pattern attribute then adding it like adding value to div.

Hope this helps.

like image 80
Zakaria Acharki Avatar answered Feb 03 '26 04:02

Zakaria Acharki