<html>
<body>
<form action="/demo/htmldom/action_page.php">
密码:<input type="password" id="myPsw" name="usr_psw" required>
<input type="submit">
</form>
<p>请单击“试一试”按钮,了解是否必须在提交表单前填写密码字段。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myPsw").required;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>