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

js-textfield-validation

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-textfield-validation

An npm Package to validate textfield value.

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Textfield Validation

An npm Package to validate textfield value.

How to install

# with npm
npm install js-textfield-validation

API

Some validations are chainable.

Available validations

ValidationDescriptionResponseChainable
alphanumericOnlyTo accept alphanumeric only.stringYes
dollarValueTo create a value with two decimal places.stringYes
noSpaceTo remove all the spaces.stringYes
removeNumTo remove all the number.stringYes
numOnlyTo remove all the non integer.stringYes
removeLeadingZeroTo remove all the leading zero.stringYes
singleSpaceTo accept single space between two characters only.stringYes
validateEmailTo check whether value is an valid email format.booleanNo
wordOnlyTo remove all non alphabet.stringYes

HOW TO USE

Simple example:

import React, { Component } from "react";
import TextField from "@material-ui/core/TextField";
import Validation from "js-textfield-validation";

class App extends Component {
  constructor() {
    super();
    this.state = {
      name: "",
    };
  };

  handleChange = event => {
    let validatedName = new Validations(event.target.value).removeNum().singleSpace().value;
    this.setState({ name: validatedName });
  };

  render() {
    return (
      <div>
        <TextField
          id="name"
          label"Name"
          variant="outlined"
          placeholder="Enter your name here."
          value={ this.state.name }
          onChange={ this.handleChange }
        />
      </div>
    );
  };
};

LICENSE

LICENSE.md

Keywords

FAQs

Package last updated on 01 Apr 2019

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