Skip to content

nanachi-code/numericInput-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

numericInput-js

Force input fields to accept numeric value only.

Setup

  1. Include jQuery(local or CDN)
<script src="jquery-3.5.1.min.js"></script>
  1. Include plugin
<script src="numericInput.js"></script>

Usage

There are 2 ways to init an numeric input:

  1. Using jQuery selector
<input type="text" name="phone" />

<script src="jquery-3.5.1.min.js"></script>
<script src="numericInput.js"></script>
<script>
    // Call on specified input
    $(`input[name="phone"]`).numericInput();
</script>
  1. Using HTML numericinput and maxdigits attribute.
<input type="text" name="phone" numericinput maxdigits="3" />

<script src="jquery-3.5.1.min.js"></script>
<script src="numericInput.js"></script>

API Documentation

jQuery(selector).numericInput(options)

options (default: {maxDigits: null})

Type: plainObject

options accepts following properties:

  • maxDigits: Maximum amount of digits.

Init numericInput on a specified jQuery selector.

Changelog

1.0.0 Init release

1.0.1 Now run on dynamically added input.

1.0.2 Fix bug with dynamically added input.

About

Force input fields to accept numeric value only.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published