新增注册(页面跳转)及登录(弹窗)功能
This commit is contained in:
38
js/register.js
Normal file
38
js/register.js
Normal file
@ -0,0 +1,38 @@
|
||||
$('#submitRegister').on('click', function () {
|
||||
console.log('クリックされました')
|
||||
|
||||
const username = $('#registerUsername').val().trim();
|
||||
const email = $('#registerEmail').val().trim();
|
||||
const password = $('#registerPassword').val().trim();
|
||||
const confirmPassword = $('#registerConfirmPassword').val().trim();
|
||||
|
||||
if (!email || !password || !confirmPassword) {
|
||||
alert('必須項目をすべて入力してください');
|
||||
return;
|
||||
}
|
||||
|
||||
if (password !== confirmPassword) {
|
||||
alert('パスワードが一致しません');
|
||||
return;
|
||||
}
|
||||
|
||||
const requestData = {
|
||||
username: username || null,
|
||||
email: email,
|
||||
password: password
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: 'http://192.168.1.192:8085/api/user/register',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(requestData),
|
||||
success: function () {
|
||||
// alert('登録成功!');
|
||||
window.location.href = 'index.html';
|
||||
},
|
||||
error: function () {
|
||||
alert('登録に失敗しました');
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user