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

[Input] add option to validate user input on input with type number #10479

Open
nnaydenow opened this issue Jan 7, 2025 · 0 comments
Open

[Input] add option to validate user input on input with type number #10479

nnaydenow opened this issue Jan 7, 2025 · 0 comments

Comments

@nnaydenow
Copy link
Contributor

Discussed in #10447

Originally posted by Xidai December 30, 2024
Consider this scenario, there is a Input with type="Number", I only type '-' into the Input and focus out, the '-' is not a valid number, so the event.target.value returns empty, but what we need is to highlight it with error state to tell the user this is not a valid number so that he/she should modify it. But I can not get the real input '-'. Is there any way I can achieve that?

Hello colleagues,

Native input has valueAsNumber property which validates the value, but it returns NaN whether the input is empty, but it still might be valid if required is not set.

In native input it could also be checked with :valid / :invalid selectors which are controlled by element internals.

@nnaydenow nnaydenow changed the title [Input] How can I get the value if the input value is not a valid number for type="Number" Input? [Input] add option to validate user input on input with type number Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant