0

This is my code:

<input type="password" id="centraPassword" placeholder="Enter Centra Password" class="form-control" ng-model="centraPassword" />

<label>
   <input type="checkbox" ng-model="centrapasswordcheck" >
   I have a Centra Travels password
</label>
<button type="submit" class="btn btn-info" ng-disabled="continueEmailButton" id="btnContinue" ng-click="ContinueDetails()">Continue</button>

This is my angularjs Code:

$scope.ContinueDetails = function () {
if ($scope.centrapasswordcheck == true)
         {
if ($scope.centraPassword == '' || $scope.centraPassword == null) {
alert("please enter your password")
    return;
             }
         }
 }

In the above code when I click the Continue button, first check the checkbox checked or not after it will check enter the password or not.

2
  • Is there a question here? Commented Sep 19, 2015 at 9:41
  • When i click a check box ng-model does't workout Commented Sep 19, 2015 at 9:47

1 Answer 1

1

var module = angular.module('myApp', []);
module.controller('myCtrl', function($scope) {
  
  $scope.centrapasswordcheck = true;
  
  $scope.ContinueDetails = function () {
    if ($scope.centrapasswordcheck == true) {
      if ($scope.centraPassword == '' || $scope.centraPassword == null) {
        alert("please enter your password 1");
      }
      else {
        alert("Password Validated");
      }
    } else {
      alert('Please Check Checkbox');
    }
    alert('Coming out of the fuction');
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<body ng-app="myApp" ng-controller="myCtrl">
<input type="password" id="centraPassword" placeholder="Enter Centra Password" class="form-control" ng-model="centraPassword" />

<label>
   <input type="checkbox" ng-model="centrapasswordcheck" >
   I have a Centra Travels password
</label>
<button type="submit" class="btn btn-info" ng-disabled="!centrapasswordcheck" id="btnContinue" ng-click="ContinueDetails()">Continue</button>
  </body>

Check Once Is it what you want or something else

Remove alerts ands code what you want

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

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.