6

I would like to disable button after one click.

Code:

<button id="submitRequest" class="btn btn-primary btn-active"
        ng-disabled="!frmRequest.$valid||!r.DataUseAgreement||(!chkBMT&&!chkOncore&&!chkCAISIS&&!chkLIMS&&!chkFCR)"
        ng-click="SaveData()">
  <i class="fa fa-save"></i> Submit
</button>

How to disable this one after one click?

Thanks!

2
  • what do you mean by one click? Commented Jul 27, 2016 at 16:26
  • all inputs, checkboxes and selects add required Commented Jul 27, 2016 at 16:31

4 Answers 4

7

Simple. You write to element a bit of javascript, like onclick="this.disabled=true" .

<button id="submitRequest" onclick="this.disabled=true" class="btn btn-primary btn-active" ng-disabled="!frmRequest.$valid||!r.DataUseAgreement||(!chkBMT&&!chkOncore&&!chkCAISIS&&!chkLIMS&&!chkFCR)" ng-click="SaveData()"><i class="fa fa-save"></i> Submit</button>

Sign up to request clarification or add additional context in comments.

1 Comment

This will disable the button one click,but it doesnt allow form submission too for first click.
5

Disabling button after one click

<input type="submit" name="Submit" class="btn btn-primary"
value="Submit" ng-disabled="button.disabled"/>

In Controller,where u submit the form just add

scope.button={};
scope.button.disabled=true;

This disables the button after one click form submission

Comments

2

In your SaveData() function, add below line in beginning of function:

$scope.saving=true;

then, in your ng-disabled condition, add additional condition:

saving||!frmRequest.$valid||!r.DataUseAgreement||(!chkBMT&&!chkOncore&&!chkCAISIS&&!chkLIMS&&!chkFCR)

Comments

1

It is quite straight forward. You just have to add one more Boolean condition in your ng-disable statement.

 <button class="btn btn-info" ng-click="ctrl.isSubmit()" ng-disabled="ctrl.submitClicked">Submit</button>

And in your Controller

var vm=this;
vm.submitClicked=false;

vm.isSubmit= function(){
vm.submitClicked= true;
}

Here is a Plunker that I made for you

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.