jQuery Mobile: Numbers only input field?
html, jquery, jquery-mobile
Solution
Use input type of number. Don't give up on server side validation though!
Problem
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> ```