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.Regular Expression to validate 14 digit number using C# and VB.Net in ASP.Net<p>Hi <a class="username" rel="chetan"> chetan</a>,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <pre class="brush: html">&lt;asp:TextBox runat=&#34;server&#34; ID=&#34;txtValue&#34; /&gt; &lt;asp:Button Text=&#34;Validate&#34; runat=&#34;server&#34; OnClick=&#34;ValidateText&#34; /&gt;</pre> <p><strong><span style="text-decoration: underline;">C#</span></strong></p> <pre class="brush: csharp">protected void ValidateText(object sender, EventArgs e) { System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(&#34;^[0-9]{14}$&#34;); if (regex.IsMatch(txtValue.Text.Trim())) { ClientScript.RegisterClientScriptBlock(this.GetType(), &#34;&#34;, &#34;alert(&#39;Valid&#39;)&#34;, true); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), &#34;&#34;, &#34;alert(&#39;Invalid&#39;)&#34;, true); } }</pre> <p><span style="text-decoration: underline;"><strong>VB.Net</strong></span></p> <pre class="brush: vb">Protected Sub ValidateText(ByVal sender As Object, ByVal e As EventArgs) Dim regex As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(&#34;^[0-9]{14}$&#34;) If regex.IsMatch(txtValue.Text.Trim()) Then ClientScript.RegisterClientScriptBlock(Me.[GetType](), &#34;&#34;, &#34;alert(&#39;Valid&#39;)&#34;, True) Else ClientScript.RegisterClientScriptBlock(Me.[GetType](), &#34;&#34;, &#34;alert(&#39;Invalid&#39;)&#34;, True) End If End Sub</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><img src="https://i.imgur.com/OANyDKq.jpg" alt="" width="242" height="180" /></p>https://www.aspforums.net:443/Threads/344432/Regular-Expression-to-validate-14-digit-number-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/344432/Regular-Expression-to-validate-14-digit-number-using-C-and-VBNet-in-ASPNet/Tue, 20 Aug 2019 06:58:35 GMT