0

I have an URL input <input id="my_input" type = "email> and I want to change the pattern attribute. I don't want to do that inline but using the following CSS file

#my_input{
pattern:".*test.*"
}

I get a "unknown property: pattern"

1 Answer 1

1

The pattern attribute is a HTML attribute not a CSS property. Here is an example:

<input type="text" pattern="[a-z]{4,8}" title="4 to 8 lowercase letters">

HTML attributes must be provided inline and cannot be provided in external CSS files.

It is important to note that the HTML attribute if very limited, and it it more common to use JavaScript for input validation due to its broader functionality.

For more information read the MDN docs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.