Tee
Tee

Reputation: 57

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!

Upvotes: 1

Views: 6096

Answers (1)

w35l3y
w35l3y

Reputation: 8783

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.

Upvotes: 1

Related Questions