SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 49 of 49
  1. #26
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    var sRealname
    oRE.test(sRealname)
    if (sRealName == '')
    else if (sRealName.length < 4)

    You really need to pay more attention to your variable names. Javascript is case sensitive.

  2. #27
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have both password and retype password field right,
    when i give password as ravi it should say password should be atleast 6 characters long but instead it is asking enter retype password ,after entering both only it is checking.but i want to check for password field if it is less than 6 characters it should display the message "password should be atleast 6 characters long"....
    what to do......

  3. #28
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    It depends on the order of the checks. If you look at your code, you'll see that the first password check checks if one or both of the password fields are empty.
    If you want another check to be performed first, you'll have to move it up.

    By the way, right now the password check function always returns false...

  4. #29
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    then i need to use length function to check the password length for password field right..

  5. #30
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    You already have the correct check for the length, but it's executed after the empty password field check. Change the order of the checks if you want to have the length check first.

  6. #31
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how to change the order of the password function...

  7. #32
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    how to change the order of the password function...

    Just move the check you want to move above or below another check? You know, cutting and pasting the piece of code that performs the check you want to move?

  8. #33
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have changed but also not accepting...

    function validatePwd(form) /* password & retype-password verification*/
    {
    var invalid = ' ';
    minLength = 6;
    var pw1 = form.password.value;
    var pw2 = form.password2.value;

    if (form.password.value.length < minLength)
    {
    alert('Your password must be at least ' + minLength + ' characters long. Try again.');
    return false;
    }

    if (pw1 == '' || pw2 == '')
    {
    alert('Please enter your password twice.');
    return false;
    }

    if (document.form.password.value.indexOf(invalid) > -1)
    {
    alert('Sorry, spaces are not allowed.');
    return false;
    }
    else
    {
    if (pw1 != pw2)
    {
    alert('You did not enter the same new password twice. Please re-enter your password.');
    return false;
    }
    else
    {
    alert('Passwords Match.');
    return false;
    }

    return false;
    }
    }

  9. #34
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    but also not accepting...
    What do you mean?

    Like I told you before, you have to explain what test you are doing. The values, the result, the desired result.

  10. #35
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    after entering valid username and valid email id fields and clicking the submit button it should ask for enter password field but when i click submit button
    the username and email id passwords are not displayed

  11. #36
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    It works fine for me.
    It tells me the password has to be more at least 6 characters long.

  12. #37
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no before entering for password field only it is displaying the message "password should be atleast six characters long"

  13. #38
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    no before entering for password field only it is displaying the message "password should be atleast six characters long"
    Yes, that's what you wanted:
    when i give password as ravi it should say password should be atleast 6 characters long but instead it is asking enter retype password

  14. #39
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ya that is what i asked you whether to include the length field for password.

  15. #40
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    You already do that. What do you think this does?
    Code:
    if (form.password.value.length < minLength)

  16. #41
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think with out using else condition it is failing....

  17. #42
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    i think with out using else condition it is failing....
    So add it, and see what happens

  18. #43
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    now too before entering password field only it is displaying the message "your password should be atleast 6 characters long"...

  19. #44
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    I know
    That's because you put that test first.

    It's not like javascript knows what you want, it just does what you tell it to do. Tell it to do what you want it to do.

    What are the checks you want to do on the passwords? Make a list, and put them in the right order.

  20. #45
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what we need to add then so that it should not display any alert message before entering in the password field...

  21. #46
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    If you click submit before entering the password, you don't want to show any alert message?

  22. #47
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    exactly that is what i want

  23. #48
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Ok, so add a new check to the email function (first check): if the email is empty, return false (but without any alert message).

  24. #49
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i am getting an alert message for before inserting any value for password
    not to email function....


Bookmarks

Posting Permissions

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