Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save davidystephenson/34c6289bbbf3d3b4cca52c2f8f48c3ae to your computer and use it in GitHub Desktop.

Select an option

Save davidystephenson/34c6289bbbf3d3b4cca52c2f8f48c3ae to your computer and use it in GitHub Desktop.
console.log('user registration')
const form = document.getElementById('registerForm')
console.log('form', form)
form.addEventListener('submit', (event) => {
event.preventDefault()
const fullname = document.getElementById('fullname')
const username = document.getElementById('username')
const email = document.getElementById('email')
const contact = document.getElementById('contact')
const password = document.getElementById('pswd')
console.log('password', password)
const confirmPassword = document.getElementById('confirm-password')
console.log('confirmPassword', confirmPassword)
if (password.value !== confirmPassword.value) {
alert('Passwords do not match')
return
}
const user = {
fullname: fullname.value,
username: username.value,
email: email.value,
contact: contact.value,
password: password.value
}
const userJson = JSON.stringify(user)
localStorage.setItem('user', userJson)
window.location.href = './sign-in.html'
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment