이 코드는 무엇이 잘못 되었나요? 길이를 확인하여 3 ~ 5 자인지 확인하려고합니다.자바 스크립트 텍스트 유효성 확인
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form name = "form1" id="form1">
<input type="text" name="text1" id="text1" value="" onblur="testText(3,5)" />
</form>
<script type="text/javascript">
function testText(minNum,maxNum){
var str = document.form1.text1.value.length;
if(str >= minNum && str <= maxNum){
alert('valid');
}else{
ALERT('ERROR: \N REQUIRED LENGTH IS AT LEAST' + minNum);
document.form1.text1.focus();
}
}
</script>
</body>
</html>
무엇이 작동하지 않습니까? – Dogbert
그래서? 어떤 브라우저를 사용합니까? 문제가 무엇입니까? – iehrlich
입력 된 텍스트가 유효한지 여부에 대한 경고가 팝업됩니다. 나는 크롬을 사용하고있다. – droidus