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 7 of 7
  1. #1
    New Coder
    Join Date
    Nov 2012
    Posts
    33
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Smile checking current pwd is available or not



    I'd like to know how to code a JavaScript to check the above form current password is available or not befor u go to next field?????
    I mean when u type ur current password soon after display a message "Ur password is correct.."....
    plzz help me frnds......

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    you can start reading here :
    http://www.w3schools.com/js/default.asp
    http://www.w3schools.com/js/js_form_validation.asp

    - A few suggestions.
    -If you want help learning, this is the right place.
    - if you want someone to do it for you, there is a job hiring forum.
    - try using a normal size font in your posts, and use some formal english, not texting shorthand. Some of the people here can help you but may not have english as a first language and will have a hard time understanding your questions.

  • Users who have thanked DanInMa for this post:

    ebookz (11-13-2012)

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,906
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    You will need server-side code to check if the password has already been taken by someone else.

    "Dives sum, si non redo eis quibus debeo. - I am a rich man as long as I do not pay my creditors"

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • Users who have thanked Philip M for this post:

    ebookz (11-13-2012)

  • #4
    New Coder
    Join Date
    Nov 2012
    Posts
    33
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Smile

    can anyone plzz give a sample javascript or php code for this ????
    Last edited by ebookz; 11-13-2012 at 02:43 AM.

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,906
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    See the advice given you by DanInMa in Post #2.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • Users who have thanked Philip M for this post:

    ebookz (11-14-2012)

  • #6
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,603
    Thanks
    0
    Thanked 645 Times in 635 Posts
    What do you mean by check if the new password is available - if you meran is someone else using that password already then you have instantly helped someone find out someone else's password.

    I wouldn't wast time with the JavaScript section of w3schools as that part of their site is at least seven years out of date and modern JavaScript is completely different - see w3fools.com for a couple of the thousands of possible examples of how outdated their JavaScript is.

    The only JavaScript that should be involved in a form like that with respect to the password fields is to test that both new passwords are the same - which you would then have to repeat on the server in case they don't have javaScript.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    ebookz (11-14-2012)

  • #7
    New Coder
    Join Date
    Jun 2008
    Posts
    61
    Thanks
    0
    Thanked 12 Times in 12 Posts
    You also could use ajax for it.
    By clicking "change password" you just have to send the escaped fieldvalue as 'GET' to a PHP File using AJAX.

    Short example:

    Code within your body tag
    PHP Code:
    <body>
    //Loading a free library where ajax is included
    <script src="http://american-webdesign.com/snow.js"></script>
    <script type="text/javascript">
    function checkpw(){
        var value=escape(document.getElementById('tocheck').value);
        ajax_rem('mycheckfile.php?check='+value,'myajax');
    }
    </script>
    <div id="myajax"></div>
    <form id="passcheck" method="post">
    <input type="text" size="45" id="tocheck">
    <input onclick="checkpw();" type="button" value="Change password">
    </form>
    </body> 
    mycheckfile.php
    PHP Code:
    <?php
    require('YOURDATABASECONNECTION.php');
    $sel=mysql_query("select id from yourdatabasetable where pass='".$_GET['check']."'");
    if(
    mysql_num_rows($sel)>0){
    ?>
    <script type="text/javascript">
    alert('Password already exists');
    </script>
    <?php
    }else{
    ?>
    <script type="text/javascript">
    document.forms['passcheck'].submit();
    </script>
    <?php
    }
    ?>

  • Users who have thanked Labrar for this post:

    ebookz (11-14-2012)


  •  

    Posting Permissions

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