Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 779
Index Avatar asked Jun 03 '12 15:06

Index


1 Answers

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

like image 178
Madara's Ghost Avatar answered Sep 28 '22 15:09

Madara's Ghost