使用复选框验证文本框
Validation for textbox by using checkbox
这是我的代码:
<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>
这是我的angularjs代码:
$scope.ContinueDetails = function () {
if ($scope.centrapasswordcheck == true)
{
if ($scope.centraPassword == '' || $scope.centraPassword == null) {
alert("please enter your password")
return;
}
}
}
在上面的代码中,当我点击Continue按钮时,首先勾选checkbox checked or not,之后会勾选是否输入密码。
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>
检查一次是你想要的还是其他的
删除警报并根据需要编写代码
这是我的代码:
<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>
这是我的angularjs代码:
$scope.ContinueDetails = function () {
if ($scope.centrapasswordcheck == true)
{
if ($scope.centraPassword == '' || $scope.centraPassword == null) {
alert("please enter your password")
return;
}
}
}
在上面的代码中,当我点击Continue按钮时,首先勾选checkbox checked or not,之后会勾选是否输入密码。
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>
检查一次是你想要的还是其他的
删除警报并根据需要编写代码