Skip to content

A lightweight, zero-dependency JavaScript/TypeScript library for validating form inputs with customisable rules. Supports length limits, alphanumeric enforcement, HTML blocking, and more.

License

Notifications You must be signed in to change notification settings

garydavisonos/validation-form-fields

Repository files navigation

Validation Form Fields

A lightweight, zero-dependency JavaScript/TypeScript library for validating form inputs with customisable rules. Supports length limits, alphanumeric enforcement, HTML blocking, and more.

Code Quality Publish to npm Version ESLint TypeScript

Table of Contents- Installation

Installation

To install the library, you can use npm or yarn:

npm install validation-form-fields

Usage

Basic examples:

import  { ValidationFormFields } from 'validation-form-fields';

  useEffect(() => {
    const input = document.getElementById('name') as HTMLInputElement;
    if (input){
      ValidationFormFields.attachValidation(input, {
        minLength: 3,
        maxLength: 255,
        allowAlphanumericOnly: true,
        blockHTML: true,
        requireNonEmpty: true,
      });
    }
  }, []);
import  { ValidationFormFields } from 'validation-form-fields';

const input = document.getElementById('name');
if (input){
    ValidationFormFields.attachValidation(input, {
    minLength: 3,
    maxLength: 255,
    allowAlphanumericOnly: true,
    blockHTML: true,
    requireNonEmpty: true,
    });
}

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

A lightweight, zero-dependency JavaScript/TypeScript library for validating form inputs with customisable rules. Supports length limits, alphanumeric enforcement, HTML blocking, and more.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published