In this article I will explain with an example, how to implement GST Number validation using RegularExpressionValidator in ASP.Net.
The GST Number entered in the TextBox will be validated using Regular Expression (Regex) and ASP.Net RegularExpressionValidator.
 
 
HTML Markup
The following HTML Markup consists of a TextBox, an ASP.Net RegularExpressionValidator and a Button control.
The RegularExpressionValidator has been set with a Regular Expression for validating GST Number in the ValidationExpression property.
The following conditions must satisfy for a GST Number to be termed as valid.
1. It should be 15 characters long.
2. The first 2 characters should be a digit representing State Code.
3. The next 10 characters should be PAN number of the taxpayer.
Note: For more details on PAN Card Number validation, please refer my article PAN Card Number validation using RegularExpressionValidator in ASP.Net.
 
4. The 13th character should be any digit (1-9) or an alphabet.
5. The 14th character should be Z by default.
6. The 15th character should be an alphabet or any digit. 0-9.
Example: 06BZAHM6385P6Z2
GST Number:
<asp:TextBox ID="txtGSTNumber" runat="server" CssClass="gst" />
<asp:RegularExpressionValidator ID="rgxAadhaar" runat="server" ControlToValidate="txtGSTNumber"
    ValidationExpression="[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$"
    ErrorMessage="Invalid GST Number." ForeColor="Red"></asp:RegularExpressionValidator>
<hr />
<asp:Button ID="btnSubmit" Text="Submit" runat="server" />
 
 
CSS Class
The following CSS class is used.
gst – It will force the letters to be UPPER case.
<style type="text/css">
    body { font-family: Arial; font-size: 10pt; }
    .gst { text-transform: uppercase; }
</style>
 
 
Screenshot
GST (Goods and Services Tax) Number validation using RegularExpressionValidator in ASP.Net
 
 
Demo
 
 
Downloads