To check if a user already exists in a database, you will have to make some server-side code, not only javascript (client-side).
You have to use AJAX to make a call to a server script (in PHP or ASP for example), sending the name entered by the user. The server-side script will check by making a SQL query to check in the DB, and return its response to your javascript if yes or not the user already exists.
Here is an example using jQuery :
HTML 
Your name : <input type="text" id="username" />
<button id="myButton" value="check if user exists" />
JAVASCRIPT
<script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
<script>
    $(function () {
        //when you will click on your button
        $('#myButton').click(function(){
            //get prompted username
            var username = $('#username').val();
            //check if username exists making AJAX call
            checkUserName(username);
        });
    });
    function checkUserName(name)
    {
        //ajax call to your server-side script
        $.ajax({
            url: 'myscript.php',
            type: 'POST',
            data: 'username='+name,
            success: function (response) {
                //if response is 1, a user with this name already exists
                if(response == 1)
                {
                    alert('user already exists');
                }
                //the name is available
                else
                {
                    //redirect to your "signup.html" page
                    window.location.href="signup.html"
                    alert('name is available');
                }
            }
        });
    }
</script>
PHP
myscript.php
<?php
//you have to secure and check the variable, depending what you will use, mysqli_real_escape_string, or escape properly the received variables
$username = $_POST['username'];
//query example, you have to ajust depending on your database & user table
$sql = 'SELECT COUNT(username) FROM db.user WHERE username = "'.$username.'"';
//exec your query
//if the count returned result is > 0, there is a user with this name, return 1 for example
//else, user with this name does not exist, return 0 for example
if($return == 1)
    echo "1";
else
    echo "0";
exit;
Here is the main idea :) try to make a JSFiddle code and try in it, and write here if you have some more problems !
Regards,
Julien