Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

textfield-length-validation

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

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.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
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

Package last updated on 17 Mar 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc