First I want to validate some of the field values entered or not. After that When i click the submit button, the button must be disabled after one click to avoid duplicate submission. How to do that using javascript?
<script type="text/javascript" language="javascript">
    function ValidateIt() {
      if (document.getElementById('ddlProblemCategory').value == 0) {
           alert("Please fill some value");
           return false;
      }
           return true;
    }
    function DisableIt() {
        if (ValidateIt() == true)
          document.getElementById('btnSaveProblem').disabled = true;
    }  
</script>
                Call function submitbtn onclick of the button.
Use
function submitbtn(){
getElementById("Submit_id").disabled=true;
//Validation code goes here
}
                        You can add an onclick handler to your button:
document.getElementById("idOfButton").onclick = function() {
    //disable
    this.disabled = true;
    //do some validation stuff
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With