Index
Index

Reputation: 2381

jQuery Mobile: Numbers only input field?

I'm making a website based on jQuery Mobile. On a particular field I would like to accept only numbers, or more precisely 4 digits. I noticed that the slider input does this (when you tap the field on your phone it brings up a "numbers only keyboard").

However I'm not interested in the slider itself as this as I want the user to type in an exact number (for example 4687 is a bit hard to achive with a slider on a touch phone).

Is there an alternative to the slider or is there a neat way to hide the actual slider?

<div data-role="fieldcontain">
    <fieldset data-role="controlgroup">
        <label for="slc_length">
            Length
        </label>
        <input type="range" name="slider" id="slc_length" value="500" min="8" max="9999" data-highlight="true" />
    </fieldset>
</div>

Upvotes: 9

Views: 12357

Answers (2)

Cristian Weiser
Cristian Weiser

Reputation: 91

<input type="number" name"abc">

Upvotes: 4

Madara&#39;s Ghost
Madara&#39;s Ghost

Reputation: 174977

Use input type of number. Don't give up on server side validation though!

Upvotes: 11

Related Questions