locked
Java Script RRS feed

  • Question

  • User-147238865 posted

    Using Java Script validation how to check password field (constraint is password must be 6 to 14 character only) on asp.net webpage?

    How to change the mode of textbox to password textbox in asp.net ?

    Monday, August 25, 2014 10:22 AM

Answers

  • User724169276 posted

    how to check password field (constraint is password must be 6 to 14 character only) on asp.net webpage?

    Hello,

    Use a Regular expression validator with a regex expression of below:

    ^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).{6,14}$

    How to change the mode of textbox to password textbox in asp.net ?

    There is a property named TextMode in textbox , just set it Password.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 25, 2014 10:32 AM
  • User-1151753377 posted

    Hi SURYA_TECH,

    According to your description, I know you want to validate your password by JavaScript.

    If so, I made a test on my computer, please refer to the code below:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            function ValidatePassword() {
                var v = document.getElementById("TextBox1");
                var passw = /^[A-Za-z]\w{6,14}$/;
                if (v.value.match(passw)) {
                    alert('Correct !')
                    return true;
                }
                else {
                    alert('The format is wrong...!')
                    return false;
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:TextBox ID="TextBox1" runat="server" TextMode="Password"  AutoPostBack="true" onblur="ValidatePassword()"></asp:TextBox>
        </div>
        </form>
    </body>
    </html>

    About the below point, you can set the TextMode="Password" property.

    How to change the mode of textbox to password textbox in asp.net ?

     

    More information about how to validate field by Javascript, please refer to the link below:

    http://www.w3resource.com/javascript/form/password-validation.php

     

    If you have any other questions, please feel free to post this forum.

    Best Regards,

    Summer

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 26, 2014 1:42 AM

All replies

  • User724169276 posted

    how to check password field (constraint is password must be 6 to 14 character only) on asp.net webpage?

    Hello,

    Use a Regular expression validator with a regex expression of below:

    ^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).{6,14}$

    How to change the mode of textbox to password textbox in asp.net ?

    There is a property named TextMode in textbox , just set it Password.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 25, 2014 10:32 AM
  • User-1151753377 posted

    Hi SURYA_TECH,

    According to your description, I know you want to validate your password by JavaScript.

    If so, I made a test on my computer, please refer to the code below:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            function ValidatePassword() {
                var v = document.getElementById("TextBox1");
                var passw = /^[A-Za-z]\w{6,14}$/;
                if (v.value.match(passw)) {
                    alert('Correct !')
                    return true;
                }
                else {
                    alert('The format is wrong...!')
                    return false;
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:TextBox ID="TextBox1" runat="server" TextMode="Password"  AutoPostBack="true" onblur="ValidatePassword()"></asp:TextBox>
        </div>
        </form>
    </body>
    </html>

    About the below point, you can set the TextMode="Password" property.

    How to change the mode of textbox to password textbox in asp.net ?

     

    More information about how to validate field by Javascript, please refer to the link below:

    http://www.w3resource.com/javascript/form/password-validation.php

     

    If you have any other questions, please feel free to post this forum.

    Best Regards,

    Summer

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 26, 2014 1:42 AM