根据客户名称,用户可以查看发货单选按钮但是如果没有客户发货单选按钮则不应该检查另一个单选按钮取件是否应该检查该条件。
我正在做的工作正常,但单选按钮没有检查..任何人都可以帮助我。 这是我的代码
<div class="form-row-redio-btn">
<div class="LevelDiv" style="padding: 5px 15px;">Shipment Type</div>
<input type="radio" data-ng-value="true" id="radioOne" data-ng-model="IsPickup" name="account" checked data-ng-checked="IsPickup"/>
<label for="radioOne" class="radio">Pick up</label>
<input type="radio" data-ng-value="false" id="radioTwo" name="account" data-ng-model="IsPickup" data-ng-change="checkCustomer();"/>
<label for="radioTwo" class="radio">Delivery</label>
</div>
JS
//check if the customer is selected or not.
$scope.checkCustomer = function () {
if (!$scope.CustomerName) {
toastr.clear();
$scope.IsPickup = true;
console.log($scope.IsPickup);
toastr["error"]('Please select a customer as the shipment type is delivery!');
return false;
}
}
答案 0 :(得分:0)
模型您使用相同模型的两个单选按钮,如果客户是空的,您可以将模型更改为true,您想要检查
<强> JS 强>
$scope.IsPickup = true;
$scope.checkmyname = function () {
if (!$scope.CustomerName) {
alert('No customer so default to Delivery')
$scope.IsPickup = false;
$scope.Isdelivery = true;
}
else
{
$scope.IsPickup = true;
$scope.Isdelivery = false;
alert('Have customer')
}
}
<强> HTML 强>
<input type="text" ng-model="CustomerName" />
<div class="form-row-redio-btn">
<div class="LevelDiv" style="padding: 5px 15px;">Shipment Type</div>
<input type="radio" data-ng-value="true" id="radioOne" data-ng-model="IsPickup" name="account" checked data-ng-checked="IsPickup"/>
<label for="radioOne" class="radio">Pick up</label>
<input type="radio" data-ng-value="true" id="radioTwo" name="delivery" data-ng-model="Isdelivery" data-ng-change="checkCustomer();"/>
<label for="radioTwo" class="radio">Delivery</label>
</div>
<button ng-click="checkmyname()"> check custmor name </button>
在输入中输入客户名称并在输入中删除客户名称并检查参考https://plnkr.co/edit/NAJqlM7kNeJfv5lzNUg1