0.1.1 • Published 1 year ago

textfield-length-validation v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Text field length validation

This should be used in the following manner:

Install with the command:

npm install --save textfield-length-validation

Then, in your code:

import { lengthValidation } from 'textfield-length-validation';

let isValid = lengthValidation(input, counter, maxCharacters);

Where:

  • input is the input field
  • counter could be a <span> tag to show the character countdown
  • maxCharacters is the maximum number of characters allowed

Example of use

<input type="text" id="input"/>

<div>
    Characters left <span id="textCounter"></span>
</div>
import { lengthValidation } from 'textfield-length-validation';

const input = document.getElementById('input');
const counter = document.getElementById('textCounter');
const maxCharacters = 10;

lengthValidation(input, counter, maxCharacters);

As it returns a boolean, it can be used to disable a submit button.

0.1.1

1 year ago

0.1.0

1 year ago