Input Password required Property - Set a password field to be a required part of form submission: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Password

Description

Input Password required Property - Set a password field to be a required part of form submission:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form action="#">
   Password: <input type="password" id="myPsw" name="usr_psw">
  <input type="submit">
</form>/*from  w w  w.j a  v a  2  s.co  m*/

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("myPsw").required = true;
    document.getElementById("demo").innerHTML = "set";
}
</script>

</body>
</html>

Related Tutorials