Home > Code > Javascript > Disable Button and Submit button after one click using JavaScript

Disable Button and Submit button after one click using JavaScript

by John Prathip   on Oct 06, 2015   Category: Javascript   |  Views: 519    |  Points: 25   |  Silver 


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form>
<input type="button" id="btn" value="Button" />
<input type="submit" id="btnSubmit" value="Submit" />
<script type="text/javascript">
window.onbeforeunload = function () {
var inputs = document.getElementsByTagName("INPUT");
for (var i = 0; i < inputs.length; i++) {
if (inputs.type == "button" || inputs.type == "submit") {
inputs.disabled = true;
}
}
};
</script>
</form>
</body>
</html>


Post Code  |  Code Snippet Home

User Responses


No response found, be the first to review this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts