<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>input 태그의 값 읽기</title> <link rel="stylesheet" href="style_js.css"> </head> <body> <form name="myform"> 사용자ID <input type="text" name="userId"><br> 패스워드 <input type="password" name="passwd"><br> <input type="submit" value="log in" onClick="getInput()"> </form> <script> function getInput() { const id = document.myform.userId; const pw = document.myform.passwd; if (pw.value.length <= 4) alert(`${id.value}님 패스워드를 변경하세요`); else alert(`${id.value}님 환영합니다`); } </script> </body> </html>