Socket
Socket
Sign inDemoInstall

textfield-length-validation

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    textfield-length-validation

This module modifies the character countdown for text fields and shows a message if it has more characters than admited.


Version published
Weekly downloads
1
Maintainers
1
Install size
2.75 kB
Created
Weekly downloads
 

Readme

Source

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.

Keywords

FAQs

Last updated on 17 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc