2014-10-27 110 views
1

我有這種形式,有一組單選按鈕。我可以驗證等領域,但在確認無線電buttons.I驗證我的其他領域類似這樣的如何驗證離子單選按鈕

<div class="form-group" ng-class="{ 'has-error' : (userForm.originAcc.$invalid || userForm.originAcc.$pristine) && submitted }"> 
    <label class="labelColor"><h5><b>Source Account Number *</b></h5></label> 
    <select id="originAcc" name="originAcc"style="margin: auto; width:100%" ng-model="user.originAcc" ng-options="account.account for account in accountsArr"required> 
     <option value="" >--Select Account--</option> 
    </select> 
    <span class="help-inline" ng-show="(userForm.originAcc.$pristine && submitted) ||(userForm.originAcc.$error.required && submitted)" >Source Account Number cannot be left blank.</span> 
</div> 

與使用有錯誤的I類驗證這些fields.How我可以確認就是這樣的單選按鈕失敗了嗎?

我的單選按鈕html的

<label class="labelColor"><h5><b>Select Standing Order Type</b></h5></label> 
<div class="list"> 
<ion-radio ng-repeat="item in clientSideList" ng-value="item.value" ng-model="user.clientSide" required> 
    {{ item.text }} 
</ion-radio> 
</div> 

單選按鈕JS

$scope.move = function() { 

    var path; 
    switch($scope.user.clientSide) { 
     case 'ftso': path = 'app/so/fundtransferOrder'; break; 
     //case 'oaso': path = 'app/so/ownstanding'; break; 
     case 'utso': path = 'app/so/utilitytransferOrder'; break; 
    } 
    $location.path(path); 

}; 

回答

1

HTML部分

<div class="form-group" ng-class="{ 'has-error' : thirdPartyForm.clientSide.$invalid && thirdPartyForm.clientSide.$dirty && submitted || (thirdPartyForm.clientSide.$invalid && thirdPartyForm.clientSide.$pristine) && submitted }" ng-init="data.type ='INTERNAL';transactionTypeChange('INTERNAL');hideFields();banksArray();"> 

    <div class="list"> 
     <ion-radio ng-repeat="item in accTypeList" name="clientSide" id="clientSide" ng-value="item.value" ng-model="data.type" ng-change="transactionTypeChange(item.value);hideFields(item.value);banksArray();pop();" required> 
      {{ item.text }} 
     </ion-radio> 
    </div> 
    <span class="help-inline" ng-show="submitted && userForm.clientSide.$error.required" >Type cannot be left unselected.</span> 
</div> 

JS PART

$scope.accTypeList = [{text: "*************", value:"INTERNAL"}, {text:"Other Banks", value:"OTHER"}]; 

    $scope.transactionTypeChange = function(obj){ 

    if(obj.localeCompare('OTHER')==0){ 
    $scope.listOne= [{"id":"1","name":"Transfer (SLIPS)"},{"id":"2","name":"Transfer (CEFTS)"}]; 
    $scope.data.transtype = $scope.listOne[0]; 
    $scope.validateDestAccFlag = false; 
    } else if(obj.localeCompare('INTERNAL')==0){ 
    $scope.listOne = [{"id":"1","name":"****************"}]; 
    $scope.data.transtype = $scope.listOne[0]; 
; 
    $scope.validateAccFlag= true; 
    $scope.validateDesitinationAccount($scope.data.origin, $scope.data.beneAcc); 

    }