JavaScript Program to Save 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>HTML Form and Cookie</title>
        function storeCookie()
            var un = document.getElementById('uname').value;
            var pd = document.getElementById('pwd').value;

            document.cookie = "Password=" + pd;
            alert("Cookie Updated!\n" + document.cookie);
<form name="myform" action="#">
    Enter the Username <input type="text" id="uname"/><br><br>
    Enter the Password <input type="password" id="pwd"/><br><br>
    <input type="button" value="Submit" onclick="storeCookie()">