ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Validate OTP using JavaScript in ASP.Net<p>Hi <a class="username" rel="sambath"> sambath</a>,</p> <p>Please refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML </strong></span></p> <pre class="brush: html">&lt;script type=&#34;text/javascript&#34;&gt; function Check() { var message = &#39;&lt;%=Session[&#34;otp&#34;] %&gt;&#39;; var otp = document.getElementById(&#39;txtOTP&#39;).value; var countdigit = otp.length; if (countdigit == 4) { if (otp == message) { document.getElementById(&#39;lblMessage&#39;).innerHTML = &#34;Correct OTP&#34;; } else { document.getElementById(&#39;lblMessage&#39;).innerHTML = &#34;Incorrect OTP&#34;; } } else { document.getElementById(&#39;lblMessage&#39;).innerHTML = &#34;&#34;; } return false; } &lt;/script&gt; &lt;div&gt; Enter OTP: &lt;asp:TextBox ID=&#34;txtOTP&#34; class=&#34;otp&#34; runat=&#34;server&#34; MaxLength=&#34;4&#34; TextMode=&#34;Password&#34; onkeyup=&#34;Check();&#34; /&gt; &lt;br /&gt; &lt;asp:Label ID=&#34;lblMessage&#34; runat=&#34;server&#34; /&gt; &lt;/div&gt;</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { Session[&#34;Otp&#34;] = &#34;1234&#34;; } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not Me.IsPostBack Then Session(&#34;Otp&#34;) = &#34;1234&#34; End If End Sub</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://imgur.com/RzmY8Zj.gif" alt="" width="236" height="146" /></p>https://www.aspforums.net:443/Threads/479954/Validate-OTP-using-JavaScript-in-ASPNet/https://www.aspforums.net:443/Threads/479954/Validate-OTP-using-JavaScript-in-ASPNet/Mon, 15 Oct 2018 07:52:15 GMT