locked
Regex Help RRS feed

  • Question

  • User1489758560 posted

    Hi,

    I have asp.net multi line textbox and i wanted to allow only alphanumeric, comma and space. of any other character typer will have to show the error message. Tried the below code and not working. don't know what mistake am doing. could anyone please help me in this

    <asp:TextBox ID="txtCheck" runat="server" Columns="64" Rows="20"
                        TextMode="MultiLine" Wrap="true"></asp:TextBox>
                    <asp:RegularExpressionValidator ID="regexpCheck" runat="server" ControlToValidate="txtCheck" ForeColor ="red"
                ValidationExpression="^[A-Za-z\\s,]*$"  ErrorMessage="*Valid characters: Alphabets,Numbers and Special Characters (,)." />
    Thursday, March 26, 2020 2:08 PM

Answers

  • User475983607 posted

    Hi,

    I have asp.net multi line textbox and i wanted to allow only alphanumeric, comma and space. of any other character typer will have to show the error message. Tried the below code and not working. don't know what mistake am doing. could anyone please help me in this

    <asp:TextBox ID="txtCheck" runat="server" Columns="64" Rows="20"
                        TextMode="MultiLine" Wrap="true"></asp:TextBox>
                    <asp:RegularExpressionValidator ID="regexpCheck" runat="server" ControlToValidate="txtCheck" ForeColor ="red"
                ValidationExpression="^[A-Za-z\\s,]*$"  ErrorMessage="*Valid characters: Alphabets,Numbers and Special Characters (,)." />

    What does "not working" mean?  Your RexEx does not allow numbers and you have an extra slash. 

    ^[A-Za-z\d\s,]*$

    Online RegEx Tester.

    https://regex101.com/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 26, 2020 4:03 PM

All replies

  • User475983607 posted

    Hi,

    I have asp.net multi line textbox and i wanted to allow only alphanumeric, comma and space. of any other character typer will have to show the error message. Tried the below code and not working. don't know what mistake am doing. could anyone please help me in this

    <asp:TextBox ID="txtCheck" runat="server" Columns="64" Rows="20"
                        TextMode="MultiLine" Wrap="true"></asp:TextBox>
                    <asp:RegularExpressionValidator ID="regexpCheck" runat="server" ControlToValidate="txtCheck" ForeColor ="red"
                ValidationExpression="^[A-Za-z\\s,]*$"  ErrorMessage="*Valid characters: Alphabets,Numbers and Special Characters (,)." />

    What does "not working" mean?  Your RexEx does not allow numbers and you have an extra slash. 

    ^[A-Za-z\d\s,]*$

    Online RegEx Tester.

    https://regex101.com/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 26, 2020 4:03 PM
  • User1489758560 posted

    Thanks a lot buddy. my bad did not look at the double slash. it worked for me.

    Thursday, March 26, 2020 6:25 PM