/input-with-regex

An Input box that takes in an optional validationRegex prop and formats the text appearing in it accordingly

Primary LanguageTypeScript

Input with Regex

Created with CodeSandbox

Desription

This is an Input component that allows us to put restrictions on what can the user type in. For example,

  <Input type="text" validationRegex={/[a-zA-Z]/} />

The validationRegex prop accepts a RegExp object or a Regular expression. Both Paste and Typing are handled for a given regex by the input. If you don't pass validationRegex, it works like a normal input box.