<style>
.btn-custom {
color: #fff;
background-color: #198754;
border-color: #ffffff;
}
.btn-custom:hover, .btn-custom:focus, .btn-custom:active, .btn-custom.active, .open>.dropdown-toggle.btn-custom {
color: #fff;
background-color: #157347;
border-color: #ffffff;
}
</style>
<script>
const update_url = "https://rebeccaaa.tk/api/club/update/";
// const update_url = "http://localhost:8192/api/club/update/";
function update(){
var email = document.getElementById("username").value;
var pwd = document.getElementById("password").value;
var name = document.getElementById("name").value;
var purpose = document.getElementById("purpose").value;
var types = document.getElementById("types").value;
var president = document.getElementById("president").value;
var advisor = document.getElementById("advisor").value;
var meeting = document.getElementById("meeting").value;
var info = document.getElementById("info").value;
// confirm requirements, matching
securePassword();
validatePassword();
// store data in JavaScript object
let data = {email: email, password: pwd, name: name, types: types, purpose: purpose, president: president, advisor: advisor, meeting: meeting, info: info, official: null};
console.log(data);
// get ID of currently logged in user from sessionStorage
const storedData = JSON.parse(localStorage.getItem('ID'));
console.log(storedData);
const options = {
method: 'POST',
mode: 'cors',
cache: 'no-cache',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data), // convert to JSON
};
const update_url_id = update_url + storedData; // url with ID
fetch(update_url_id, options)
.then(response => {
// check for response errors
if (response.status !== 200) {
error('POST API response failure: ' + response.status);
return;
}
// valid response
console.log(data);
// redirect on successful login
window.location.href = "{{ site.baseurl }}/profile";
})
// catch fetch errors (ie Nginx ACCESS to server blocked)
.catch(err => {
error(err + " " + url);
});
}
// Something went wrong with actions or responses
function error(err) {
// log as Error in console
console.log(err);
}
</script>
EMAIL
PASSWORD
RETYPE PASSWORD
CLUB NAME
PURPOSE
CLUB TYPE(S)
(Advocacy/Awareness, Athletics, Competition, Computer Science, Cultural, Environment, Other Interests, Service, STEM, Visual/Performing Arts)
CLUB PRESIDENT
STAFF ADVISOR
MEETING TIME AND LOCATION
ADDITIONAL INFO
(Contact info, registration forms, social media, website)
Update
<script>
function validatePassword(){
if(password.value != confirm_password.value){
confirm_password.setCustomValidity("Passwords Don't Match"); // form won't be submitted
} else {
confirm_password.setCustomValidity(''); // matching
}
confirm_password.reportValidity();
}
// Get references to the password and confirm_password input fields
const password = document.getElementById("password");
const confirm_password = document.getElementById("confirm_password");
// Add an event listener to the confirm_password field that calls validatePassword() on input
confirm_password.addEventListener("input", validatePassword);
var myInput = document.getElementById("password");
// When the user clicks on the password field, show the message box
myInput.onfocus = function() {
document.getElementById("message").style.display = "block";
}
// When the user clicks outside of the password field, hide the message box
myInput.onblur = function() {
document.getElementById("message").style.display = "none";
}
// When the user starts to type something inside the password field
password.addEventListener("input", securePassword);
function securePassword() {
// Validate lowercase letters
var lowerCaseLetters = /[a-z]/g;
if(myInput.value.match(lowerCaseLetters)) {
} else {
myInput.setCustomValidity("Password Doesn't Meet Requirements");
myInput.reportValidity();
}
// Validate capital letters
var upperCaseLetters = /[A-Z]/g;
if(myInput.value.match(upperCaseLetters)) {
} else {
myInput.setCustomValidity("Password Doesn't Meet Requirements");
myInput.reportValidity();
}
// Validate numbers
var numbers = /[0-9]/g;
if(myInput.value.match(numbers)) {
} else {
myInput.setCustomValidity("Password Doesn't Meet Requirements");
myInput.reportValidity();
}
// Validate length
if(myInput.value.length >= 8) {
} else {
myInput.setCustomValidity("Password Doesn't Meet Requirements");
myInput.reportValidity();
}
}
</script>