Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
butter-studio
Commits
3c84b7c1
Commit
3c84b7c1
authored
Jul 24, 2021
by
한규민
Browse files
signUp 수정
parent
aa372d52
Changes
1
Show whitespace changes
Inline
Side-by-side
client/src/components/Signup/Signup.js
View file @
3c84b7c1
...
...
@@ -36,6 +36,12 @@ const Signup = () => {
...
user
,
[
e
.
target
.
name
]:
e
.
target
.
value
})
if
(
e
.
target
.
name
===
"
userBirthday
"
||
e
.
target
.
name
===
"
userMbum
"
){
setUser
({
...
user
,
[
e
.
target
.
name
]:
String
(
e
.
target
.
value
)
})
}
}
//id(중복확인 체크, 형식 에러)
...
...
@@ -72,7 +78,6 @@ const Signup = () => {
setLoading
(
false
);
}
}
const
handleOnSummit
=
async
(
e
)
=>
{
...
...
@@ -96,29 +101,32 @@ const Signup = () => {
}
}
//
유효성 검사 함수
const
vaildationData
=
(
text
,
compareValue
,
error
)
=>
{
//
비교하여 error메세지 반환
const
vaildationData
=
(
text
,
compareValue
,
error
)
=>
{
if
(
text
!==
compareValue
)
{
setErrorMsg
(
errorMsg
=>
({
...
errorMsg
,
[
error
]:
true
}));
}
else
{
setErrorMsg
(
errorMsg
=>
({
...
errorMsg
,
[
error
]:
false
}));
}
}
//유효성 검사
const
va
l
idation
=
(
)
=>
{
setPreId
(
user
.
userId
);
//아이디 유효성 검사
if
((
user
.
userId
.
length
<
5
))
{
setErrorMsg
(
errorMsg
=>
({
...
errorMsg
,
error
Id
:
tru
e
}));
}
else
if
((
user
.
userId
.
length
>=
5
)
&&
(
overlapId
===
true
)
)
{
//
아이디 비번
유효성 검사
const
vai
l
dation
IdPw
=
(
text
,
minValue
,
error
)
=>
{
if
((
text
<
minValue
)){
setErrorMsg
(
errorMsg
=>
({...
errorMsg
,
[
error
]:
true
}));
}
else
if
(
text
>=
minValue
)
{
setErrorMsg
(
errorMsg
=>
({
...
errorMsg
,
[
error
]:
fals
e
}));
if
(
overlapId
===
true
){
if
(
preId
!==
user
.
userId
){
setOverlapId
(
false
);
}
}
else
if
(
user
.
userId
>=
5
){
setErrorMsg
(
errorMsg
=>
({
...
errorMsg
,
errorId
:
false
}));
}
}
//유효성 검사
const
validation
=
()
=>
{
setPreId
(
user
.
userId
);
//아이디 유효성 검사
vaildationIdPw
(
user
.
userId
.
length
,
5
,
"
errorId
"
);
//별명 유효성 검사
vaildationData
((
user
.
userNickName
.
length
===
0
),
false
,
"
errorNickName
"
);
// 생일 유효성 검사
...
...
@@ -126,14 +134,15 @@ const Signup = () => {
// 휴대폰 유효성 검사
vaildationData
(
user
.
userMbnum
.
length
,
11
,
"
errorMbnum
"
);
// 비밀번호 유효성 검사
vaildation
Data
(
user
.
userPassword
.
length
,
8
,
"
errorPassword
"
);
vaildation
IdPw
(
user
.
userPassword
.
length
,
8
,
"
errorPassword
"
);
// 비밀번호 확인 유효성 검사
vaildationData
(
user
.
userRePassword
,
user
.
userPassword
,
"
errorRePassword
"
);
// 최종 유효성 검사
if
(
overlapId
&&
(
Object
.
values
(
errorMsg
).
some
((
element
)
=>
(
element
))
===
false
))
{
}
else
if
(
!
overlapId
&&
(
Object
.
values
(
errorMsg
).
some
((
element
)
=>
(
element
))
===
false
)){
throw
new
Error
(
"
먼저 아이디 중복확인을 해주세요
"
)
setErrorMsg
(
errorMsg
=>
({...
errorMsg
,
errorId
:
false
}));
throw
new
Error
(
"
먼저 아이디 중복확인을 해주세요
"
);
}
else
{
throw
new
Error
(
"
유효하지 않은 데이터입니다.
"
);
}
...
...
@@ -180,23 +189,22 @@ const Signup = () => {
<
div
className
=
"
d-flex flex-column
"
>
<
div
className
=
{
styles
.
inputContent
}
>
<
label
className
=
{
styles
.
signupLabel
}
>
휴대폰
번호
<
/label
>
<
input
className
=
{
`
${
styles
.
input
}
${
styles
.
inputSize
}
`
}
type
=
"
number
"
name
=
"
userMbnum
"
id
=
"
userMbnum
"
placeholder
=
"
-없이 11자리 입력
"
onChange
=
{
handleUserOnChange
}
min
=
"
0
"
max
=
"
99999999999
"
required
/>
<
input
className
=
{
`
${
styles
.
input
}
${
styles
.
inputSize
}
`
}
type
=
"
number
"
name
=
"
userMbnum
"
id
=
"
userMbnum
"
placeholder
=
"
-없이 11자리 입력
"
onChange
=
{
handleUserOnChange
}
min
=
""
max
=
"
99999999999
"
required
/>
<
/div
>
{
errorMsg
.
errorMbnum
&&
<
p
className
=
{
styles
.
passwordConfirmError
}
>-
없이
숫자
11
자리를
입력해주세요
.
<
/p>
}
<
/div
>
<
div
className
=
"
d-flex flex-column
"
>
<
div
className
=
{
`
${
styles
.
inputContent
}
`
}
>
<
label
className
=
{
styles
.
signupLabel
}
>
비밀번호
<
/label
>
<
input
className
=
{
`
${
styles
.
input
}
${
styles
.
inputSize
}
`
}
type
=
"
password
"
name
=
"
userPassword
"
id
=
"
password
"
placeholder
=
"
8자리
입력
"
onChange
=
{
handleUserOnChange
}
maxLength
=
"
8
"
required
/>
<
input
className
=
{
`
${
styles
.
input
}
${
styles
.
inputSize
}
`
}
type
=
"
password
"
name
=
"
userPassword
"
id
=
"
password
"
placeholder
=
"
8
~11
자리
사이
"
onChange
=
{
handleUserOnChange
}
maxLength
=
"
11
"
required
/>
<
/div
>
{
errorMsg
.
errorPassword
&&
<
p
className
=
{
styles
.
passwordConfirmError
}
>
8
자리를
입력해주세요
.
<
/p>
}
{
errorMsg
.
errorPassword
&&
<
p
className
=
{
styles
.
passwordConfirmError
}
>
8
~
11
자리
사이로
입력해주세요
.
<
/p>
}
<
/div
>
<
div
className
=
"
d-flex flex-column
"
>
<
div
className
=
{
styles
.
inputContent
}
>
<
label
className
=
{
styles
.
signupLabel
}
>
비밀번호
확인
<
/label
>
<
input
className
=
{
`
${
styles
.
input
}
${
styles
.
inputSize
}
`
}
type
=
"
password
"
name
=
"
userRePassword
"
id
=
"
userRePassword
"
placeholder
=
"
8자리
입력
"
onChange
=
{
handleUserOnChange
}
maxLength
=
"
8
"
required
/>
<
input
className
=
{
`
${
styles
.
input
}
${
styles
.
inputSize
}
`
}
type
=
"
password
"
name
=
"
userRePassword
"
id
=
"
userRePassword
"
placeholder
=
"
8
~11
자리
사이
"
onChange
=
{
handleUserOnChange
}
maxLength
=
"
11
"
required
/>
<
/div
>
{
errorMsg
.
errorRePassword
&&
<
p
className
=
{
styles
.
passwordConfirmError
}
>
비밀번호가
일치하지
않습니다
.
<
/p>
}
<
/div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment