JAVA Servlet에서 데이터를 체크하고 경고창 띄울 때

KSOJIN·2023년 6월 24일
0

taxcare

목록 보기
2/10
post-thumbnail

▼ 화면이 로드되기 전에 경고창 띄우기

<%if(request.getAttribute("isExist") != null) {%>
<script>alert('이미 존재하는 ID 입니다.');</script>
<%} %>

▼ 화면이 로드된 후 경고창 띄우기

<script>
$(document).ready(function() {
	var isExist = <%=request.getAttribute("isExist")%>;
    //문자열로 인식하지 않음 ex) "1"이 아니라 1(number)로 인식
    if(isExist == 1) alert('이미 존재하는 ID 입니다.);
});
</script>

0개의 댓글