locked
Problem with Range validator Control RRS feed

  • Question

  • User1414682904 posted

    Hello Friends, I want to usea RangeValidator Control which will validate my Password field  where i want to check that if user enters less than 6 characters passwrod then it will prompt an error .


    I want to give minimum & maximun password size ie minimum 6 characters. It could be alphanumeric & combination of special characters.  ]]

    Maximum size should be 15 characterss.Same any combination o Alpha numeric or special charactors.


    I have done it through Custom Validator .But how can i do this with Range Validator control.

    Please give a simple sample to understand ......



    Tuesday, April 6, 2010 1:24 AM

Answers

  • User1123702521 posted

    A simple regular expression validator would do the trick. Simply define the lower and upper boundary of your text length, like this.. [\s\S]{6,15} Here is a sample code for you...

            <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
            <asp:RegularExpressionValidator ID="REV1" runat="server" ErrorMessage="Password can only be between 6 to 15 characters.!" 
                ControlToValidate="txtPassword" ValidationExpression="[\s\S]{6,15}"></asp:RegularExpressionValidator>



     

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 6, 2010 2:35 AM
  • User-1636183269 posted
    Refer my thread http://forums.asp.net/p/1541279/3755908.aspx#3755908

    (?=^.{6,15}$)(?=.*\d)(?=.*[@#$%^&+=!])(?=.*[A-Z])(?=.*[a-z]).*$ ( including special character require)



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 6, 2010 2:44 AM
  • User878889002 posted

    hi

    Use ajaxcontroltoolkit in ur project. See this link for help. this wud be easy n make ur site looking good and u can do all the things u want in one control

    https://www.asp.net/ajax/ajaxcontroltoolkit/Samples/PasswordStrength/PasswordStrength.aspx 

     

    mark if it is the answer

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 6, 2010 2:48 AM

All replies

  • User-1823825456 posted

    i dont think u can do the same in range validator cause as far my understanding, range validator is used only to chek the value is within the specified range or not. its not anythink with the no of chars or others

    Tuesday, April 6, 2010 2:25 AM
  • User1123702521 posted

    A simple regular expression validator would do the trick. Simply define the lower and upper boundary of your text length, like this.. [\s\S]{6,15} Here is a sample code for you...

            <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
            <asp:RegularExpressionValidator ID="REV1" runat="server" ErrorMessage="Password can only be between 6 to 15 characters.!" 
                ControlToValidate="txtPassword" ValidationExpression="[\s\S]{6,15}"></asp:RegularExpressionValidator>



     

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 6, 2010 2:35 AM
  • User-691245060 posted

    Hello,

    USe RegularExpressionValidator instead...Rangevalidator is to check the range of the input to be in the MAximum and minimum values specified....so you cant use that....if you dont want to go for RegularExpressionValidator...then the other choices would be a customValidator, Javascript....

     <asp:RegularExpressionValidator ID="regex" runat="server" 
      ControlToValidate="TextBox1" ErrorMessage="Password Length Minimum 6 characters and maximum 15 characters" 
      ValidationExpression="^[0-9A-Za-z]{6,15}$"></asp:RegularExpressionValidator>

    Hope this post helps you...Thanks.

    Tuesday, April 6, 2010 2:40 AM
  • User-1636183269 posted
    Refer my thread http://forums.asp.net/p/1541279/3755908.aspx#3755908

    (?=^.{6,15}$)(?=.*\d)(?=.*[@#$%^&+=!])(?=.*[A-Z])(?=.*[a-z]).*$ ( including special character require)



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 6, 2010 2:44 AM
  • User878889002 posted

    hi

    Use ajaxcontroltoolkit in ur project. See this link for help. this wud be easy n make ur site looking good and u can do all the things u want in one control

    https://www.asp.net/ajax/ajaxcontroltoolkit/Samples/PasswordStrength/PasswordStrength.aspx 

     

    mark if it is the answer

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 6, 2010 2:48 AM