Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10

Thread: Validation

  1. #1
    New Coder
    Join Date
    Oct 2002
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Validation

    I am used to use vbscript doing form validation. How I can
    validate user's inital their new password as following rule in JS.


    1) At Least one embedded numeric

    2) Charactor can't repeat more than twice.

    3) Length can not more than 10 charactors. (I am Okay for this rule)

    Any help

  • #2
    Regular Coder
    Join Date
    Aug 2003
    Location
    Loughborough University
    Posts
    427
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is this any good:
    Attached Files Attached Files
    AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
    BFG GeForce 6800 Ultra OC 256Mb
    3 * Kingston 256Mb PC3200 DDR400
    Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150

  • #3
    New Coder
    Join Date
    Oct 2002
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks!

    It works Great! It help me LOT since it works lot of diff from VBScript. Thanks for your share the coding!!!

    One more question if you don't mind.

    If I don't allow charactors repeat more than twice the way as below example. Does it a major change for the coding?

    Valid password: awnnq86pzn

    Invalid password: awnnnq86pz


    Thanks
    Owen

  • #4
    New Coder
    Join Date
    Oct 2002
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Valid password: awnnq86pzn
    Invalid password: awnnnq86pz

    Valid password: awnn66qpzn
    Invalid password: awnnq666Z


    Thanks
    Owen

  • #5
    Regular Coder
    Join Date
    Aug 2003
    Location
    Loughborough University
    Posts
    427
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, the code would be slightly different. A bit like this in fact:
    Attached Files Attached Files
    AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
    BFG GeForce 6800 Ultra OC 256Mb
    3 * Kingston 256Mb PC3200 DDR400
    Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150

  • #6
    New Coder
    Join Date
    Oct 2002
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Lavalamp:
    First, I am really appreciate your times for your coding. Regarding the second TXT file. it seems like didn't work for the following rule. It maybe I was confused you from last example

    Cannot contain more than two repeating characters
    (e.g., "nn" is allowed, but "nnn" is not allowed).

    Valid password: awqnn86nz

    Invalid password: awnnnq86pz


    I was read the information from
    .http://javascriptkit.com/javatutors/re2.shtml . But I can't make it work for testing a string if more than two repeating characters.

    No matter what, Thanks LOT!
    Owen

  • #7
    Regular Coder
    Join Date
    Aug 2003
    Location
    Loughborough University
    Posts
    427
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oops, it looks as though this:

    if(charcount>maxtogether-2){break;}

    should have been this:

    if(charcount>maxtogether-1){break;}

    It should work now though:
    Attached Files Attached Files
    AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
    BFG GeForce 6800 Ultra OC 256Mb
    3 * Kingston 256Mb PC3200 DDR400
    Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150

  • #8
    New Coder
    Join Date
    Oct 2002
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks, it works now!!!!

  • #9
    Regular Coder
    Join Date
    Aug 2003
    Location
    Loughborough University
    Posts
    427
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Happy to help.
    AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
    BFG GeForce 6800 Ultra OC 256Mb
    3 * Kingston 256Mb PC3200 DDR400
    Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150

  • #10
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Or, you can just use this
    Code:
    function check_pass( pass )
    {
        return ( /\d/.test( pass ) && !/(.)\1\1/.test( pass ) && pass.length >= 10 );
    }
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •