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.Common function to validate IFSC code using Regular Expressions in ASP.Net<p>Hi <a class="username" rel="bhushan98"> bhushan98</a>,</p> <p>Create a function that will accept input from user and then validate the input value using RegularExpressions.</p> <p>Check this example which accepts the below condition.</p> <ol style="list-style-type: undefined;"> <li>Length should be 11</li> <li>First 4&nbsp;characters are alphabets with upper and lower character</li> <li>Last seven characters are number</li> </ol> <p>If you want to change the condition then change the RegularExpressions pattern.</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;txtIFSCCode&#34; /&gt; &lt;asp:Button Text=&#34;Validate&#34; runat=&#34;server&#34; OnClick=&#34;Validate&#34; /&gt;</pre> <p><strong><span style="text-decoration: underline;">Code</span></strong></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Validate(object sender, EventArgs e) { bool isValid = ValidateIFSCCode(txtIFSCCode.Text.Trim()); Response.Write(isValid ? "Valid" : "Invalid"); } public bool ValidateIFSCCode(string ifscCode) { System.Text.RegularExpressions.Regex regx = new System.Text.RegularExpressions.Regex("^[A-Za-z]{4}[0-9]{7}$"); return regx.Matches(ifscCode).Count &gt; 0 ? regx.Matches(ifscCode)[0].Success : false; }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Validate(ByVal sender As Object, ByVal e As EventArgs) Dim isValid As Boolean = ValidateIFSCCode(txtIFSCCode.Text.Trim()) Response.Write(If(isValid, "Valid", "Invalid")) End Sub Public Function ValidateIFSCCode(ByVal ifscCode As String) As Boolean Dim regx As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("^[A-Za-z]{4}[0-9]{7}$") Return If(regx.Matches(ifscCode).Count &gt; 0, regx.Matches(ifscCode)(0).Success, False) End Function</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><img src="https://i.imgur.com/bxGNIy8.gif" alt="" width="259" height="136" /></p>https://www.aspforums.net:443/Threads/720966/Common-function-to-validate-IFSC-code-using-Regular-Expressions-in-ASPNet/https://www.aspforums.net:443/Threads/720966/Common-function-to-validate-IFSC-code-using-Regular-Expressions-in-ASPNet/Mon, 09 Jul 2018 06:06:55 GMTCommon function to validate IFSC code using Regular Expressions in ASP.Net<p>Hi <a class="username" rel="bhushan98"> bhushan98</a>,</p> <p>Create a separate class file and write the code to validate the IFSC code. Then call the method in your required page.</p> <p>Please take reference to the below code and correct your code.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;div&gt; &lt;asp:TextBox runat=&#34;server&#34; ID=&#34;txtIFSCCode&#34; /&gt; &lt;asp:Button ID=&#34;Button1&#34; Text=&#34;Validate&#34; runat=&#34;server&#34; OnClick=&#34;Validate&#34; /&gt; &lt;/div&gt;</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>CS.aspx.cs</strong></p> <pre class="brush: csharp">protected void Validate(object sender, EventArgs e) { IFSC ifsc = new IFSC(); bool isValid = ifsc.ValidateIFSCCode(txtIFSCCode.Text.Trim()); Response.Write(isValid ? &#34;Valid&#34; : &#34;Invalid&#34;); }</pre> <p><strong>IFSC.cs</strong></p> <pre class="brush: csharp">public class IFSC { public bool ValidateIFSCCode(string ifscCode) { System.Text.RegularExpressions.Regex regx = new System.Text.RegularExpressions.Regex(&#34;^[A-Za-z]{4}[0-9]{7}$&#34;); return regx.Matches(ifscCode).Count &gt; 0 ? regx.Matches(ifscCode)[0].Success : false; } }</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://i.imgur.com/bxGNIy8.gif" alt="" width="259" height="136" /></p>https://www.aspforums.net:443/Threads/720966/Common-function-to-validate-IFSC-code-using-Regular-Expressions-in-ASPNet/https://www.aspforums.net:443/Threads/720966/Common-function-to-validate-IFSC-code-using-Regular-Expressions-in-ASPNet/Tue, 10 Jul 2018 01:02:39 GMT