Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Check if input value is >= 8 & <=32 & has at least 1 number!?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #44912

    Pretty sure I’m not doing this correctly:

    if (isNaN( $(“#field”).val() ) && val.length >= min && val.length <= max) {
    showMessage(‘Your password is good!’);
    }

    http://jsfiddle.net/wGVMW/

    #135788
    donpeppo
    Member

    it works?

    But i would not use javascript to do this because its easy for the user to alter.

    #135790

    Still isn’t working correctly. :/ I want it to say “Your password is good!” ONLY when there is at least one number in the password, and the password itself needs to be >= 8 chars, and <= 32 chars. I'm sorry if I didn't seem clear. Thanks for the help Mottie!

    #135791
    Alen
    Participant
    #135793

    Thanks for the help man! It works great.

    #135823
    CrocoDillon
    Participant

    } else if (val.length == nul) {
    showMessage(‘Enter in a password!’);

    will never get reached (nothing filled in shows ‘Password is too short!’)

    } else if (/d/.test(val) && val.length >= min && val.length <= max) { don’t need the if, just `} else {`, because you already know everything else evaluates to true at that point ;)

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.