Restrict Input To Only Letters Or Numbers - jQuery Key Restrictions

Restrict Input To Only Letters Or Numbers - jQuery Key Restrictions

Key Restrictions is an ultra-light (1kb minified) jQuery plugin that restricts input field to letters, numbers or alphanumeric only.

See also:

How to use it:

1. Import the jQuery jQuery Key Restrictions plugin into your document which has jQuery library loaded.

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" 
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" 
        crossorigin="anonymous">
</script>
<script rc="src/jquery-key-restrictions.js"></script>

2. Restrict an input field to letters only.

<label for="letters-input">Letters Only:</label>
<input type="text" id="letters-input">
$(function(){
  $("#letters-input").lettersOnly();
});

3. Restrict an input field to numbers only.

<label for="numbers-input">Numbers Only:</label>
<input type="text" id="numbers-input">
$(function(){
  $("#numbers-input").numbersOnly();
});

4. Restrict an input field to Alpha Numeric only.

<label for="alpha-numeric-input">Alpha Numeric Only:</label>
<input type="text" id="alpha-numeric-input">
$(function(){
  $("#alpha-numeric-input").alphaNumericOnly();
});

This awesome jQuery plugin is developed by kenryanlabso. For more Advanced Usages, please check the demo page or visit the official website.

  • Publication date: 25.04.2018
  • Source