js Cannot read properties of undefined (reading 'value')

윤윤·2024년 4월 30일

error

목록 보기
3/12

forms[0] <- 여기서 오류가 발생한 듯한데 왜인지는 모르겠음.
함수 호출하는 폼의 이름을 설정하고 폼 이름으로 value 불러오는 건 성공.

수정 전

function pwCheck(){
	var regex = /.{3,8}/ ;
	var pw = document.forms[0].passwd.value;
	alert(pw);
}//idCheck

수정 후

function pwCheck(){
	var regex = /.{3,8}/ ;
	var pw = document.regiForm.passwd.value;
	alert(pw);
}//idCheck

0개의 댓글