HTML Number Input Step Not Validating - html

I have two different number-type input fields, both with a declared min, max, and step. On one, the step works just fine with the arrows/spinner, and throws an error when someone manually enters a number that isn't divisible by the step value. The second number input field, set up exactly the same way, the step works fine with the arrows/spinner, but will allow someone to manually enter whatever value they want, and even submit the form with the "incorrect" number. (Example: step="2", and they entered and were able to submit a 5.)
the two boxes are on different pages, and the one that's giving me fits looks like this
<input style="width:75px;" type="number" id="updates_23705616199" max="120" name="updates[]" class="txtbox" value="2" min="2" data-id="23705616199" step="2">
I even extracted just this line to an html file by itself, and it still doesn't work then. The data-id field is a required bit for the page that it's in.
Please advise

Did you make sure your IDs are unique? I created a JSFiddle showing your example working. I also gave them unique names.
https://jsfiddle.net/pa9rodfL/
<input type="number" id="idName" class="className" name="nameName" min="11" max="15" step="2" >
<input type="number" id="idName2" class="className" name="nameName2" min="5" max="10" step="3" >

Related

HTML number input: how to allow decimal numbers with step=1

For a number input, is there a way to have step=1 yet allow the user to enter decimal numbers?
The reason is I want the arrows on the input box to increase/decrease the value by 1, but allow the user to enter decimals if they want to be more specific.
At the moment I have:
<input type="number" name="price" placeholder="£" step="1" id="id_price">
The arrows work as intended, but I get a validation error if 2.99 is entered, for example. Removing the step allows decimals to be entered, but the arrows now only increase/decrease by 0.01.
I am leaning towards a Javascript solution, but I was just wondering what the best solution was. Is there another option or an existing library?
<input type="number" step="any"> step any allow user to enter decimal too and increase by 1.

unable to iterate large numbers in input

I have simple input box of type number with step='0.01'. I'd like to increase the current input value by the pre-defined step value using the up and down buttons situated on the very right side.
Now everything seems to work just fine while the number is less than or equals 13 digits. If it's greater it won't neither decrease nor increase the number by the step value. It just freezes the value not letting the user change the value using the up/down buttons.
<input id="test" type="number" min="0.00" value="" placeholder="" step="0.01" />

Radio button's value attribute is only allowing numbers

I am experiencing something weird with radio buttons, and I'm hoping someone here can explain to me what is happening.
I have created a radio button like so:
<input type="radio" name="radio-smoker" value="true" />
When I load the page in the browser (Chrome), and inspect the radio button I see:
<input type="radio" name="radio-smoker" value>
The value attribute has no value.
However, when I change the value from "true" to "1", the value attribute works and the value "1" is retained.
I also noticed that if I set a value of "test1", I end up with a value of "1". It seems to strip out the letters, only allowing numbers.
I have tried to recreate this elsewhere (e.g. jsBin), without success. It only happens in the one place.
What is happening, and where can I begin to find out what's causing it?
It works for me. Inspect the element and you can see the value isn't changed on runtime.
<form action="">
<input type="radio" name="radio-smoker" value="true" > True
<br>
<input type="radio" name="radio-smoker" value="true1" > True1
</form>
After some investigating, it turns out there was a jQuery mask plugin setting a number mask on all inputs of the page. Thus why only numbers were allowed. Once that was removed, all radio button values started working as intended.

HTML input type=number- enter multiple numbers separated by commas?

Would like a HTML number field where the user can enter numbers separated by commas and spaces... like '1, 2, 3.' Right now it only accepts inputs without commas and spaces and won't let me submit the form with commas/spaces in the field.
Here's a sample of my simple input field now:
<input id="A" name="HLA-A" type="number" />
Need number field so number keyboard will pop up on smart phones.
Did a good bit of looking and I'm surprised I didn't find anything on this... perhaps there is a simple answer? Anyone have any ideas?
Thanks!
If you REALLY need type="number", then you should do as follows:
<input type="number" />,<input type="number" />,<input type="number" />
Otherwise, you could do as follows:
<input type="text" pattern="\d+, \d+, \d+" />
Both ways, some browsers may not support it.

Input specific model numbers in textbox, and nothing else

What I want to do is make it so that when a user inputs these values PIV13RT, PIV13RT2, PIV13RT3 into a text box, it will recognized. The problem is that you're able too input PIV13RT1, because the one is already present - which I don't want to be the case. Is there anyway to stop this? Thanks. Take a look at my code.
Basically, It's been tested and everything else seems to work. It's just it sees PIV13RT1 as a value when it souldn't be.
<form>
<input type="text" id="modlenumber" pattern="^[PIV13RT2-3]+{7,8}$" title="Your
Model Number." placeholder="Please Input a Modle number" size="35"
maxlength="8"><input name="" type="submit" />
</form>
Does this pattern work for you?
^DIV13RT[23]?$
You wrapped the text you're searching for (DIV13RT) with a square brackets. They're used to match any of the containing characters so it matched every value which has at least "D" or "I" or "V" or "R" or "T" and so on.