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

HTML5 validation not respected. #5883

Closed
2 tasks
Stiofan opened this issue Mar 29, 2018 · 6 comments
Closed
2 tasks

HTML5 validation not respected. #5883

Stiofan opened this issue Mar 29, 2018 · 6 comments
Labels
[Feature] Block API API that allows to express the block paradigm. Needs Technical Feedback Needs testing from a developer perspective. [Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later

Comments

@Stiofan
Copy link

Stiofan commented Mar 29, 2018

Issue Overview

HTML5 Validation is not respected by the block settings, for example "required" or for input type number the max or min values.

Steps to Reproduce (for bugs)

  1. Create a input with type=number and set the max, min and required attributes
  2. Try to submit it as empty (works, it should not)
  3. Try to submit it with out of bound values (works, it should not)

`

{
  | label: 'Height:',
  | help: 'This is the height of the map, for static maps you can only use px values.',
  | value: props.attributes.static_height,
  | type: 'number', placeholder: '400', 'max': '2000','min': '100','required': 'required', onChange: function ( static_height ) {
  | props.setAttributes({ static_height: static_height } ) }
  | }

`

Chrome, on Ubuntu

Expected Behavior

I expect it should respect the html5 validation and not submit or save the values.
I understand these values are updated live and not fully part of the form submission, so maybe our best bet is for "required" give it a red border but for max/min this should be easy enough to implement

Current Behavior

it submits and saves the out of bounds values.

Possible Solution

Screenshots / Video

Related Issues and/or PRs

Todos

  • Tests
  • Documentation
@aduth
Copy link
Member

aduth commented Mar 29, 2018

Related Slack discussion: https://wordpress.slack.com/archives/C02QB2JS7/p1522328142000263

My thoughts: We need to better understand the use cases where one would expect to use validation. I expect it has to do with having required fields for a block before allowing the post to be saved. In which case, we might want to consider taking this consideration out of the markup alone, and making it a property of the attribute itself (a required block attribute). Alternatively, or in addition, in the context of the editor, we should consider when validation should occur; immediately? At the time of save?

@Stiofan
Copy link
Author

Stiofan commented Mar 29, 2018

When i discovered it i was simply trying to add a min/max value to a number input, i only checked "required" after the fact just to see it that worked (which it didn't)

@aduth aduth added the [Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later label Mar 30, 2018
@danielbachhuber danielbachhuber added the [Feature] Block API API that allows to express the block paradigm. label Apr 10, 2018
@danielbachhuber
Copy link
Member

Related #4063

@mtias mtias added the Needs Technical Feedback Needs testing from a developer perspective. label Oct 7, 2018
@rilwis
Copy link

rilwis commented Jan 9, 2019

I would add a comment regarding the HTML5 validation for custom fields as well. If we create a meta box with a simple text input, which has required attribute, then the attribute doesn't work, neither.

@paaljoachim
Copy link
Contributor

Can we get a status update on this issue?
It is good to know if we need to leave it open or if we can close it.
Thanks!

@tellthemachines
Copy link
Contributor

I'm going to go ahead and close this as there hasn't been any recent discussion here and there's no decision on the viability of adding this feature. It can always be reopened or a new issue created if anyone wants to explore further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. Needs Technical Feedback Needs testing from a developer perspective. [Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later
Projects
None yet
Development

No branches or pull requests

7 participants