JavaScript Program to Create Email ID from name

Write a JavaScript program to create email id after entering first name, middle name and surname.

Write html script that displays textboxes for accepting name, middlename, surname of the user and a submit button. Write proper JavaScript such that when the user clicks on submit button. i) all texboxes must get disabled and change the color to “red”. and with respective labels. ii) constructs the mailid as .@msbte.com and displays mail id as message. (ex. if user enters rajni as name and pathak as surname mailid will be constructed as rajni.pathak@msbte.com) .



Source Code
<html>
<head>
    <title>Create MSBTE email id</title>
    <script>
        function constructMailId()
        {
            var fn = document.getElementById('fname').value
            var sn = document.getElementById('sname').value
            var email = fn.toLowerCase() + "." + sn.toLowerCase() + "@msbte.com"
            alert('Your mailID is: ' + email)
        }
    </script>
</head>
<body>
<form name="myform">
<p>
First name <input type="text" id="fname"/><br/>
Surname <input type="text" id="sname"/><br/>
<input type="button" value="Submit" onclick="constructMailId()"/>
</p>
</form>
</body>
</html>
Output