//Assuming there is an element with ID='test' on the page
document.getElementById('test').onclick = function(e) {
alert('Element clicked!');
};
<form action="#" method="post">
<input type="button" value="Click for a Message" onclick="window.alert('Ndanganeni Lovers Mudau');">
</form>