39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
$('#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:8080/api/user/register',
|
|
type: 'POST',
|
|
contentType: 'application/json',
|
|
data: JSON.stringify(requestData),
|
|
success: function () {
|
|
// alert('登録成功!');
|
|
window.location.href = 'index.html';
|
|
},
|
|
error: function () {
|
|
alert('登録に失敗しました');
|
|
}
|
|
});
|
|
});
|