Allow only to enter Alpha numeric values with some special chracters

4 posts, 0 answers
  1. Dhamodharan
    Dhamodharan avatar
    300 posts
    Member since:
    Sep 2010

    Posted 28 Aug 2013 Link to this post

    Hi,
    I need to allow only alpha numeric value with some special chracters ('_','-','@','.').






    Thanks
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Aug 2013 Link to this post

    Hi Dhamodharan,

    RadTextBox can be used with RegularExpressionValidator to validate the input for a specific format. Please have a look at the following code I tried which works fine at my end.

    ASPX:
    <telerik:RadTextBox ID="RadTextBox1" runat="server">
    </telerik:RadTextBox>
    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" Display="Dynamic"
        ErrorMessage="*" ForeColor="Red" ValidationExpression="^.*(?=.*[a-zA-Z])(?=.*\d)(?=.*[\.@_-]).*$"
        ControlToValidate="RadTextBox1">
    </asp:RegularExpressionValidator>
    <br />
    <telerik:RadButton ID="RadButton1" runat="server" Text="Submit" CausesValidation="true">
    </telerik:RadButton>

    Here the validation expression is
    ^.*              : Start
    (?=.*[a-zA-Z])   : Letters
    (?=.*\d)         : Digits
    (?=.*[\.@_-])    : Special characters
    .*$              : End

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dhamodharan
    Dhamodharan avatar
    300 posts
    Member since:
    Sep 2010

    Posted 29 Aug 2013 Link to this post

    Hi Shinu,
    Thanks for ur Reply.
    It works as i should enter a text with alphabet with numeric and a specified special character.
    It allows to enter other special character along with specified values. It checks as specified values are mandatory. But my requirement is to allow any type of values may be alphabets or may be numeric values or may be specified special characters or may be mixed of all as follows.
    Correct values
    ex:  Telerik
    ex: 000000
    ex:  telerik_fourms007

    Invalid Values
    ex: telerik_forums007$&% - due to wrong special chracters


    Thanks


  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 Sep 2013 Link to this post

    Hi Dhamodharan,

    Please try the following updated code to achieve your requirement.

    ASPX:
    <telerik:RadTextBox ID="RadTextBox1" runat="server">
    </telerik:RadTextBox>
    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" Display="Dynamic"
        ErrorMessage="*" ForeColor="Red" ValidationExpression="^[0-9a-zA-Z\.@_-]+$" ControlToValidate="RadTextBox1">
    </asp:RegularExpressionValidator>

    Thanks,
    Shinu.
Back to Top