Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Password Validation....

Password Validation....

Scheduled Pinned Locked Moved ASP.NET
csharpjavatoolsquestion
6 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pranavcool
    wrote on last edited by
    #1

    Hi, I have a form Changepassword.aspx. In that i have password field.I want that password field should accept at least 1 numeric 1 alphanumeric and it should be minimum 7 characters long and maximum 20 characters. how can i do that using java script or in c#. Please provide any helpful link related to this or provide me some code to achieve this task. regards,

    Pranav Dave

    T P R J 4 Replies Last reply
    0
    • P pranavcool

      Hi, I have a form Changepassword.aspx. In that i have password field.I want that password field should accept at least 1 numeric 1 alphanumeric and it should be minimum 7 characters long and maximum 20 characters. how can i do that using java script or in c#. Please provide any helpful link related to this or provide me some code to achieve this task. regards,

      Pranav Dave

      T Offline
      T Offline
      tasumisra
      wrote on last edited by
      #2

      Loop through each character of the password and count the numeric,alphanumeric or special character as per your requirement... if any of the counter is zero show the messagebox and dont let user to proced.. :)

      vikas da

      1 Reply Last reply
      0
      • P pranavcool

        Hi, I have a form Changepassword.aspx. In that i have password field.I want that password field should accept at least 1 numeric 1 alphanumeric and it should be minimum 7 characters long and maximum 20 characters. how can i do that using java script or in c#. Please provide any helpful link related to this or provide me some code to achieve this task. regards,

        Pranav Dave

        P Offline
        P Offline
        Paddy Boyd
        wrote on last edited by
        #3

        As per the first answer, or you could use a regular expression to validate the input. Has the advantage of only the expression needing to change if you decide to change your validation.

        1 Reply Last reply
        0
        • P pranavcool

          Hi, I have a form Changepassword.aspx. In that i have password field.I want that password field should accept at least 1 numeric 1 alphanumeric and it should be minimum 7 characters long and maximum 20 characters. how can i do that using java script or in c#. Please provide any helpful link related to this or provide me some code to achieve this task. regards,

          Pranav Dave

          R Offline
          R Offline
          Ranjit Viswakumar
          wrote on last edited by
          #4

          Here you go. I used this script on one of my sites-

          function validatePassword(fld) {
          var error ="";
          var pwdFilter = /^\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*$/ ;

          if (fld.value.length < 7 || fld.value.length > 20) {
          error += "-Password must be 7-20 characters\n";
          }
          if (!pwdFilter.test(tfld)) {
          error += "-Password must contain at least 1 number, lowercase, and uppercase\n";
          }

          if (error != "") {
          alert("Some fields need correction:\n" + error);
          return false;
          }
          return true;
          }

          That is the Javascript validation. You can call it onSubmit of a form-

          <form method=POST action=register.aspx name=demo onSubmit='return validateForm(this)'>

          Try that out. Good luck! Ranjit Viswakumar Professional Services Specialist HostMySite.com[^]

          J 1 Reply Last reply
          0
          • R Ranjit Viswakumar

            Here you go. I used this script on one of my sites-

            function validatePassword(fld) {
            var error ="";
            var pwdFilter = /^\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*$/ ;

            if (fld.value.length < 7 || fld.value.length > 20) {
            error += "-Password must be 7-20 characters\n";
            }
            if (!pwdFilter.test(tfld)) {
            error += "-Password must contain at least 1 number, lowercase, and uppercase\n";
            }

            if (error != "") {
            alert("Some fields need correction:\n" + error);
            return false;
            }
            return true;
            }

            That is the Javascript validation. You can call it onSubmit of a form-

            <form method=POST action=register.aspx name=demo onSubmit='return validateForm(this)'>

            Try that out. Good luck! Ranjit Viswakumar Professional Services Specialist HostMySite.com[^]

            J Offline
            J Offline
            J4amieC
            wrote on last edited by
            #5

            If you have the regular expression, just use a RegularExpressionValidator. Saves wiring up your own validation routine!

            1 Reply Last reply
            0
            • P pranavcool

              Hi, I have a form Changepassword.aspx. In that i have password field.I want that password field should accept at least 1 numeric 1 alphanumeric and it should be minimum 7 characters long and maximum 20 characters. how can i do that using java script or in c#. Please provide any helpful link related to this or provide me some code to achieve this task. regards,

              Pranav Dave

              J Offline
              J Offline
              johnpro77
              wrote on last edited by
              #6

              Asp.Net Validation Controls Open This URL jpsprince.blogspot.com/2009/02/aspnet-validation-controls.html

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups