Search code examples
javascriptforgot-passwordone-time-password

Submit form to disable?


I need to make a form with OTP generation,where the number feild will have the OTP button and when user clicks on it the OTP will be send to his registered number given. After entering the OTP the submit button should be enable.Initially the submit button should be hidden How to write a javascript code for this. Help needed.


Solution

  • You need to have 2 css class.

    1. Hide
    2. Show

    Hide will make the button's display property as none and show will make it visible.

    Initially your submit button will have a css class of hide

    In javascript create a click handler on 1'st button. When the user clicks on OPT send button. Change the css class of submit button from hide to show.

    Refer to below bin for example

    var send = document.querySelector(".send");
    var sub = document.querySelector(".submit");
    send.addEventListener('click', function(){
        sub.classList.remove('hide');
        sub.classList.add('show');
    });
    

    http://jsbin.com/jucivus/edit?html,css,js,output