This package has been deprecated

Author message:

This package is no longer maintained, and @saekitominaga/string-convert, which extracts only the conversion functions, has been released instead.

@saekitominaga/htmlformcontrolelement-convert
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Converting input value of form control

npm version

Demo

Examples

<script type="module">
import FormControlConvert from './dist/FormControlConvert.js';

for (const formControlElement of document.querySelectorAll('.js-convert')) {
  const formControlConvert = new FormControlConvert(formControlElement);
  formControlConvert.convert({
    trim: true,
    noBlankLine: true,
    toHankakuEisu: true,
  }, {
    '.': '.'
  });
}
</script>

<p><input class="js-convert"/></p>

Constructor

new FormControlConvert(
  thisElement: HTMLInputElement | HTMLTextAreaElement
)

Parameters

thisElement [required]
Target element

Methods

convert(options?: convertOptions, table?: convertTable): void
Perform the conversion
/* Specify the conversion type */
interface convertOptions {
  trim?: boolean; // Remove whitespace at both ends
  noBlankLine?: boolean; // Delete blank lines
  toHankakuEisu?: boolean; // Make alphanumeric characters half-width (Only one of `toHankakuEisu` and toZenkakuEisu` can be specified)
  toZenkakuEisu?: boolean; // Make alphanumeric characters full-width (Only one of `toHankakuEisu` and toZenkakuEisu` can be specified)
  toHankakuSpace?: boolean; // Make full-width space half-width
  combineSpace?: boolean; // Consolidate contiguous spaces
  toLowerCase?: boolean; // Make the alphabet lowercase (Only one of `toLowerCase` and `toUpperCase` can be specified)
  toUpperCase?: boolean; // Make the alphabet uppercase (Only one of `toLowerCase` and `toUpperCase` can be specified)
}

/* Proprietary conversion table (An associative array that specifies the character string before conversion as the key and the character string after conversion as the value) */
interface convertTable {
  [key: string]: string;
}

Readme

Keywords

none

Package Sidebar

Install

npm i @saekitominaga/htmlformcontrolelement-convert

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

62.8 kB

Total Files

9

Last publish

Collaborators

  • saekitominaga