Easy One Time Password Input In JavaScript – vanilla-otp.js

Category: Form , Javascript | May 23, 2023
Views Total:561 views
Official Page:Go to website
Last Update:May 23, 2023


Easy One Time Password Input In JavaScript – vanilla-otp.js


vanilla-otp.js is a simple JavaScript plugin that converts a group of input fields into a one-time password or PIN code input.

It can be used to enhance your application’s security by facilitating a secure way for users to authenticate their identity.

How to use it:

1. Download and import the vanilla-otp.js library.

<script src="vanilla-otp.js"></script>

2.  Create a group of input fields on the page.

<div class="otp-input">
  <input type="text">
  <input type="text">
  <input type="text">
  <input type="text">

3. Initialize the one-time password input.

let otp = new VanillaOTP('.otp-input');

4. Output the password string in another input field.

let otp = new VanillaOTP('.otp-input', '#result');

5. Get the password string you just typed.


6. Set the empty character. Default: sapce.


You Might Be Interested In:

Leave a Reply