Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Form text_area doesn't support the pattern attribute #3990

Closed
hansen-m opened this issue Dec 4, 2024 · 3 comments
Closed

User Form text_area doesn't support the pattern attribute #3990

hansen-m opened this issue Dec 4, 2024 · 3 comments
Milestone

Comments

@hansen-m
Copy link

hansen-m commented Dec 4, 2024

Based on the documentation and my testing the User Form text_area doesn't support the pattern attribute to check it against a regular expression. Can this be added so that it functions in the same way as text_field does?

https://osc.github.io/ood-documentation/latest/how-tos/app-development/interactive/form.html

@osc-bot osc-bot added this to the Backlog milestone Dec 4, 2024
@johrstrom
Copy link
Contributor

Hi, thanks for the issue, but unfortunately no we can't. The pattern HTML attribute only applies to text, tel, email, url, password, and search input types.

Which is to say, even if we could embed the attribute in the HTML, browsers won't respond to it.

From the MDN documentation for the same:

https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern

@hansen-m
Copy link
Author

hansen-m commented Dec 4, 2024

@johrstrom Thanks for that info, makes sense now.

Are there any examples of how this or something similar might be done within the form.js instead?

@johrstrom
Copy link
Contributor

Well I guess you'd want to attach an event handler to the launch button's onclick event. When there is a click event, validate the text area. Browsers do the validation of patterns automatically and update the HTML to show the error. You're not going to be able to do the same exact thing within javascript, but maybe a window.alert could work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants