jQuery Mobile - Textinput Number


Number input type allows the user to input numerical values.


Following example demonstrates the use of number input in the jQuery Mobile.

<!DOCTYPE html>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
         <h2>Number Input Example</h2>
         <label for = "number">Simple Number Input</label>
         <input type = "number" id = "number" data-clear-btn = "false">
         <label for = "number1">Clear the Number Field</label>
         <input type = "number" data-clear-btn = "true" id = "number1">
         <label for = "number2">Number Pattern</label>
         <input type = "number" id = "number2" pattern = "[0-9]*" data-clear-btn = "false">
         <label for = "number3">Clear the Number Pattern Field</label>
         <input type = "number" data-clear-btn = "true" id = "number3" pattern = "[0-9]*">


Let's carry out the following steps to see how the above code works −

  • Save the above html code as textinput_number.html file in your server root folder.

  • Open this HTML file as http://localhost/textinput_number.html and the following output will be displayed.

Kickstart Your Career

Get certified by completing the course

Get Started