{"size": 3068, "ext": "js", "max_stars_repo_path": "src/main/resources/static/js/register.js", "max_stars_repo_name": "Safwan-Akhtar/QA.CF-Cinema-Project.", "max_stars_repo_stars_event_min_datetime": "2020-05-26T14:55:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-26T15:05:33.000Z", "max_issues_repo_path": "src/main/resources/static/js/register.js", "max_issues_repo_name": "Safwan-Akhtar/QA.CF-Cinema-Project.", "max_issues_repo_issues_event_min_datetime": "2020-05-26T15:00:56.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-04T08:59:11.000Z", "max_forks_repo_path": "src/main/resources/static/js/register.js", "max_forks_repo_name": "Safwan-Akhtar/QA.CF-Cinema-Project.", "max_forks_repo_forks_event_min_datetime": "2020-06-11T10:15:32.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-11T10:15:32.000Z"}
{"max_stars_count": 3, "max_issues_count": 8, "max_forks_count": 1, "avg_line_length": 32.6382978723, "max_line_length": 87, "alphanum_fraction": 0.5387874837}
function checkForm(form)
{
    if(form.username.value == "") {
        alert("Error: Username cannot be blank!");
        form.username.focus();
        return false;
    }
    re = /^\w+$/;
    if(!re.test(form.username.value)) {
        alert("Error: Username must contain only letters, numbers and underscores!");
        form.username.focus();
        return false;
    }

    if(form.password.value != "" && form.password.value == form.passwordMatch.value) {
        if(form.password.value.length < 6) {
            alert("Error: Password must contain at least six characters!");
            form.password.focus();
            return false;
        }
        if(form.password.value == form.username.value) {
            alert("Error: Password must be different from Username!");
            form.password.focus();
            return false;
        }
        re = /[0-9]/;
        if(!re.test(form.password.value)) {
            alert("Error: password must contain at least one number (0-9)!");
            form.password.focus();
            return false;
        }
        re = /[a-z]/;
        if(!re.test(form.password.value)) {
            alert("Error: password must contain at least one lowercase letter (a-z)!");
            form.password.focus();
            return false;
        }
        re = /[A-Z]/;
        if(!re.test(form.password.value)) {
            alert("Error: password must contain at least one uppercase letter (A-Z)!");
            form.password.focus();
            return false;
        }
    } else {
        alert("Error: Please check that you've entered and confirmed your password!");
        form.password.focus();
        return false;
    }

    alert("You entered a valid password: " + form.password.value);
    return true;
}




const registerUser = () => {
    let forename = document.getElementById("validationServer01").value;
    let surname = document.getElementById("surname").value;
    let username = document.getElementById("username").value;
    let email = document.getElementById("email").value;
    let password = document.getElementById("password").value;
    let passwordMatch = document.getElementById("passwordMatch").value;

        axios({
            method: 'post',
            url: 'http://localhost:8181/createUser',
            data: `{
                "username" : "${username}",
                "password" : "${password}",
                "matchingPassword" : "${passwordMatch}",
                "roles" : "ROLE_USER",
                "active" : "true",
                "email" : "${email}",
                "forename" : "${forename}",
                "surname" : "${surname}"
            }`,
            headers: {'Content-Type': 'application/json' }
            })
            .then(function (response) {
                console.log(response);
                
            })
            .catch(function (response) {
                console.log(response);
            }); 
}
let registerButton = document.querySelector('#registerButton');
registerButton.addEventListener('click', registerUser);




