Hello,
I have 2 buttons on page SendOTP and ResendOTP. When clicked on SendOTP button, it should start 2 min timer and should ENABLE ResendOTP button or also can provide sample code of how generally otp works in jquery or javascript.
Also I am looking code for simple CAPTCHA.
I ma working c# asp.net framework
Thanks in advance !

Eliana BlakeRank #1,595 · 993 reputationPosted Feb 19, 2025, 11:08 AM EST
Absolutely, I can guide you on how to achieve the functionality you described using jQuery or JavaScript.
For the scenario you mentioned with the SendOTP and ResendOTP buttons, you can use the following sample code snippets:
In this code snippet:
- Clicking on the SendOTP button will trigger a 2-minute timeout, after which the ResendOTP button will be enabled and shown.
- You can enhance the `// Handle ResendOTP functionality here` section inside the `$("#resendOTP").click` function to include the actual resend functionality.
For a simple CAPTCHA implementation, you can explore libraries like Google reCAPTCHA or create a custom implementation based on your requirements. Here is a simple example of a text-based CAPTCHA using JavaScript:
This code snippet will generate a random number as the CAPTCHA, which the user needs to enter correctly in the input field. Upon submission, a validation check is performed.
I hope this helps you get started with the functionalities you requested. Let me know if you need further assistance or modifications!
Sangeetha SRank #212 · 11.4K reputationPosted Feb 19, 2025, 11:10 PM EST
Using jQuery
First, ensure you include the jQuery library in your HTML:
Then, you can use the following jQuery code to show and hide a button:
Show\/Hide ButtonHide MeAction Button $(document).ready(function() { $(\"#toggleButton\").click(function() { $(\"#actionButton\").toggle(); \/\/ Show\/Hide the action button }); });Here's how you can achieve the same effect using plain JavaScript:
Show\/Hide ButtonHide MeAction Button document.getElementById(\"toggleButton\").addEventListener(\"click\", function() { var actionButton = document.getElementById(\"actionButton\"); if (actionButton.style.display === \"none\") { actionButton.style.display = \"block\"; \/\/ Show the action button } else { actionButton.style.display = \"none\"; \/\/ Hide the action button } });$(\"#element\").toggle();to easily toggle visibility.element.style.displayto manually change visibility.