add onclick event in html code example
Example 1: button functions html
<script>
function myFunction() {
alert("ALERT");
}
</script>
<button onclick="myFunction">Click</button>
Example 2: javascript onclick
document.getElementById("Save").onclick = function ()
{
alert("hello");
//validation code to see State field is mandatory.
}