locked
Regular Expression RRS feed

  • Question

  • User-1499457942 posted

    Hi

      I have written the below expression for GSTIN but it is giving error 'InValid GST' . Below Valud is added

    21ABCDE123451Z1

    <asp:TextBox ID="txtGST" AutoComplete="Off" AutoPostBack="true" OnTextChanged="txtGST_TextChanged" class="form-control" Style="text-transform: uppercase; width: 150px" onblur="ValidateInput(this);" placeholder="GSTIN" runat="server"></asp:TextBox>
    
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ValidationGroup="pan" ErrorMessage="GST No Required" ControlToValidate="txtGST" Display="Dynamic" ></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtGST" ValidationGroup="gst" Display="Dynamic" " ErrorMessage="Invalid GST Number" ValidationExpression="^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$"></asp:RegularExpressionValidator>
    <br />
    
    

    Thanks

    Tuesday, June 19, 2018 10:04 AM

Answers

  • User475983607 posted

    There is not much we can do  other than validate the computer is correct.   The pattern does not match the input.  The underline indicates where the pattern diverges from the value. 

    ^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$

    21ABCDE123451Z1

    I use this site for debugging RegEx.

    https://regex101.com/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 19, 2018 10:47 AM