Skip to main content

How to Create OTP Code Verification using HTML, CSS & JS

 

#html #css #foryou #world #happy # website #webdesign #webdeveloper #how to #howto #trending #viral #srilanka #youtube #tiktok #blog  #howtocreate #Javascript #image #imageuploader #otp #verification #howtocreateotpverification 


Learn how to implement OTP (One-Time Password) code verification seamlessly into your web applications with this step-by-step tutorial video. Using HTML, CSS, and JavaScript, you'll discover how to design and develop a user-friendly OTP verification system, enhancing the security of your web platform. From generating random codes to validating user input, this tutorial covers the essential aspects of OTP implementation, empowering you to safeguard user accounts effectively. Watch now and level up your web development skills! Don't forget to like, share, and subscribe for more web development tutorials and tips. If you have any questions or need further assistance, feel free to leave a comment, and we'll be happy to help you out. Happy coding! Like Us On Facebook: https://facebook.com/CodingWithNexusO... Follow Us On Instagram: https://instagram.com/coding_with_nexus Follow Us On TikTok: https://www.tiktok.com/@coding.with.n... Visit For Full Codes: https://codingwithnexusofficial.blogs 

index.html 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>OTP Verification Form</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
        <h4>Enter your four digit OTP</h4>
        <form action="#">
            <div class="input-feilds">
                <input type="number" >  
                <input type="number" disabled>
                <input type="number" disabled>
                <input type="number" disabled>
            </div>

            <button> Verify OTP</button>
        </form>
    </div>
    <script src="script.js"></script>
</body>
</html>

 


style.css 

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body{
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: rgb(195, 146, 195) ;
}
.container{
    width: 300px;
    height: auto;
    padding: 40px 30px;
    background-color: #fff;
    display: flex;  
    border-radius: 20px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.container h4{
font-size: 20px;
color: #000;
font-family: sans-serif;
}
.container form{
    width: 100%;
    height:auto ;
    align-items: center;
    flex-direction: column;
    display: flex;
    padding-top: 20px;
}

form .input-feilds{
    width: 100%;
    height: auto;
    flex-direction: row;
    justify-content: space-evenly;
    display: flex;
}

.input-feilds input{
    max-width: 20%;
    height: 60px;
    border-radius: 5px;
    font-size: 25px;
    text-align: center;
    border: none;
    background: wheat;
}
.input-feilds input::-webkit-inner-spin-button,
.input-feilds input::-webkit-outer-spin-button{
    display: none;
}

.input-feilds input:focus{
    outline: 2px dotted black;
    outline-offset: 2px;
}
form button{
    margin-top: 25px;
    background: wheat;
    width: 90%;
    color: black;
    font-size: 15px;
    padding: 10px 0;
    font-weight: 600;  
    border-radius: 5px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease ;
}

form button.active{
    color: #000;
    pointer-events: auto;
    background: rgb(209, 157, 13);

}
form button:hover{
    background: white;
    border: 2px solid black;
}


script.js 

const OTPinputs = document.querySelectorAll('input')
const button = document.querySelector('button')

window.onload = ()=> OTPinputs[0].focus()

OTPinputs.forEach((input)=>{
    input.addEventListener('input', ()=>{
        const currentInput = input
        const nextInput = currentInput.nextElementSibling

        if(currentInput.value.length > 1 && currentInput.value.length == 2 )
        {
            currentInput.value = ""
        }
        if(nextInput !== null && nextInput.hasAttribute('disabled') && currentInput.value !== ""){
            nextInput.removeAttribute('disabled')
            nextInput.focus()
        }

        if(!OTPinputs[3].disabled && OTPinputs[3].value !== "" ){
            button.classList.add("active")
        }else{
            button.classList.remove('active')
        }
    })

    input.addEventListener('keyup', (e)=>{
        console.log(e);
        if(e.key == "Backspace"){
            if(input.previousElementSibling != null){
            e.target.value = ""
            e.target.setAttribute("disabled", true)
            input.previousElementSibling.focus()
        }
        }
    })
})














 

















Comments

Popular posts from this blog

How To Create a Sign Up Form Using HTML & CSS

    In this tutorial, we'll guide you through the process of creating a standard sign-up form using HTML and CSS. It's a fundamental skill for anyone interested in web development or design. This tutorial is suitable for beginners and provides a solid foundation for understanding how to create a sign-up form. If you're interested in web development or web design, this is a crucial skill to master. If you find this video helpful, please consider liking and subscribing for more web development tutorials. Let's start building your sign-up form together!  1.Create a New Folder 2.Open the Folder in Vs Code  3.Create index.html and style.css Files  4.Create Image Folder and download  Background picture to Image folder 5.Begin Coding  index.html  <! DOCTYPE html > < html lang = "en" > < head >     < meta charset = "UTF-8" >     < meta name = "viewport" content = "width=device-width, initial-scale=1.0" >

How to Create Solar System Using HTML & CSS

  🌟 Explore the Universe: Building a Solar System with HTML and CSS! 🌟 Welcome to another mind-blowing adventure on @Coding With Nexus ! 🚀 Join us as we embark on an interstellar journey to create our very own solar system using nothing but HTML and CSS. 🌌 First Create a New Folder, Then 1.Open the folder in Vs Code 2.Create index.html and style.css Files 3.Begin Coding  index.html <! DOCTYPE html > < html lang = "en" > < head >     < meta charset = "UTF-8" >     < meta name = "viewport" content = "width=device-width, initial-scale=1.0" >     < link rel = "stylesheet" href = "style.css" >     < title > Solar System </ title > </ head > < body >     < div class = "container" >         < div class = "sun" ></ div >         < div class = "earth" >             < div class = "moon" ></

How to Create Animate Mic Logo

    Embark on a design and coding adventure with our tutorial on creating and animating a microphone logo using HTML and CSS. In this concise yet comprehensive guide, we'll navigate logo design principles, emphasizing simplicity and visual balance. Seamlessly transitioning to animation, we'll bring the mic logo to life, making it dynamic and engaging. What sets this tutorial apart is its accessibility—no complex software, just the power of code.🎙️✨ #logoanimation #designtutorial #webdevelopment Don't forget to like, share, and subscribe for more web development tutorials and tips. If you have any questions or need further assistance, feel free to leave a comment, and we'll be happy to help you out. Happy coding! Like Us On Facebook:    / codingwithnexusofficial   Follow Us On Instagram:    / coding_with_nexus   Follow Us On TikTok:    / coding.with.nexus  index.html <! DOCTYPE html > < html lang = "en" > < head >     < meta