question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Input with type="number" and field rules "required|numeric" is not validating for a specific type of numbers

See original GitHub issue

I’ve faced a problem where a field is not valid if the value of it is something like this: +32.45 - decimal with a positive sign I thought the problem was in the validatorjs but it’s validating these cases.

Test cases:

  1. “+32” -> true
  2. “32.45” -> true
  3. “-32.45” -> true
  4. “+32.45” -> false

I’ve created a sandbox with a form and a sandbox with only validatorjs.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lexpromcommented, Nov 19, 2021

@foxhound87 you mean by removing this part field.bind({ type <--, placeholder }) ? If so, that’s exactly the reason the input gets text type and it’s not reproducing

0reactions
lexpromcommented, Nov 19, 2021

It’s not even working with the value “+32” for some reason

Read more comments on GitHub >

github_iconTop Results From Across the Web

<input type="number"> - HTML: HyperText Markup Language
A number input is considered valid when empty and when a single number is entered, but is otherwise invalid. If the required attribute...
Read more >
Why the number input is the worst input - Stack Overflow Blog
Either way when the number is invalid you can't get the actual value that appears on screen in the <input type="number"> field:
Read more >
How to make HTML input tag only accept numerical values?
This input field allows only numerical values. You can also specify the minimum value and maximum value that should be accepted by this...
Read more >
How to Allow Only Positive Numbers in the Input Number Type
In this snippet, we'll demonstrate how to allow only positive numbers in the input number type. You can use the “min” attribute to...
Read more >
How to force Input field to enter numbers only using ...
By default, HTML 5 input field has attribute type=”number” that is used to get input in numeric format. Now forcing input field type=”text” ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found