JavaScript Program to Store Password in Cookie

Write a JavaScript program to create a form having username and password and save the password in cookie.

Write a webpage that displays a form that contains an input for username and password. user is prompted to enter the input and password and password becomes value of the cookie. Write the JavaScript function for storing the cookie . it gets executed when the password changes.

Source Code
    <title>Store Cookie password</title>
        function storeCookie() 
            var pwd = document.getElementById('pwd').value
            document.cookie = "Password=" + pwd + ";"
            alert("Cookie Stored\n" + document.cookie)

<form name="myForm">
    Enter Username <input type="text" id="uname"/><br/>
    Enter Password <input type="password" id="pwd"/><br/>
    <input type="button" value="Submit" onclick="storeCookie()"/>
<p id="panel"></p>


"Coding Hub - Learn to code" app now available on Google Play Store