Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $("#repeatPassword, #passwordInput").on("keyup", function () {
- if($password.value != "" && $repeatPassword.value != ""){
- if($password.value != $repeatPassword.value){
- $("#repeatPassword").removeClass("is-valid").addClass("is-invalid");
- $("#repeat-password").removeClass("d-none valid-feedback").addClass("d-block invalid-feedback").text("Incorrect Password");
- matching = false;
- } else{
- $("#repeatPassword").removeClass("is-invalid").addClass("is-valid");
- $("#repeat-password").removeClass("invalid-feedback").addClass("valid-feedback").text("Correct Password");
- matching = true;
- }
- }
- });
- $("#username").on("keyup", function () {
- $.post("/username", {input: $("#username").val()}, function (data) {
- if(data.message == "EXIST"){
- $("#username").removeClass("is-valid").addClass("is-invalid");
- $("#choose-username").removeClass("d-none valid-feedback").addClass("d-block invalid-feedback").text("This username already exists");
- matchingUsername = false;
- } else{
- $("#username").removeClass("is-invalid").addClass("is-valid");
- $("#choose-username").removeClass("invalid-feedback").addClass("valid-feedback").text("Valid Username");
- matchingUsername = true;
- }
- });
- });
- $("#passwordInput").on("keyup", function () {
- if(!checkPassword($password.value)){
- $("#passwordInput").addClass("is-invalid");
- $("#choose-password").removeClass("d-none valid-feedback").addClass("d-block invalid-feedback").text("Your password must be 8-20 character long, contain letters and numbers," +
- " and must not contain spaces or special characters.");
- $("#passwordHelpBlock").addClass("d-none");
- } else{
- $("#passwordInput").removeClass("is-invalid").addClass("is-valid");
- $("#choose-password").removeClass("d-none invalid-feedback").addClass("d-block valid-feedback").text("Safe Password");
- $("#passwordHelpBlock").addClass("d-none");
- }
- });
- $("#registration-btn").on("click", function () {
- if(checkingData() && matching && !toobig && matchingUsername){
- var img = "";
- if(imageloaded != "") img = imageloaded;
- $.post("/register", { username: $username.value, password: $password.value,
- profileImg: img} , function(data){
- if(data.message == "BAD"){
- $("#alert-register").removeClass("d-none alert-success").addClass("d-block alert-danger").text("Something went wrong!");
- } else{
- var url = window.location.href;
- var pos = url.indexOf("register.html");
- window.location.href = url.substring(0, pos);
- }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement