2016-07-13 4 views
-1

を入力フォーカスアウトテキストボックスまたはユーザーの後に私はいくつかの検証メッセージを午前:ショー検証メッセージの完全

<form name="dnaform" novalidate> 
    <div style="padding-bottom:5px" ng-show="dnaform.uEmail.$pristine || dnaform.uEmail.$valid">Active directory account </div> 
    <div style="padding-bottom:5px;" ng-show="dnaform.uEmail.$dirty && dnaform.uEmail.$error.required" class="help-block">Email is Required.</div> 
    <div style="padding-bottom:5px;" ng-show="dnaform.uEmail.$error.email" class="help-block">Invalid Email.</div> 
    <input type="email" name="uEmail" class="form-control txtBoxEdit type7N" ng-model="useremail" required> 
</form> 

問題は、それが即座に検証メッセージ、電子メールのテキストボックスにユーザーの種類に何かが表示されますが、私がしたいということですユーザーが完全に電子メールテキストを入力したとき、またはテキストボックスのフォーカスを入力したときにメッセージを表示する。

+1

をぼかし、この機能をチェックしてください! – Rayon

+0

@ develper033ほんとうに働いていますが、もう一度動かないのです。あなたはフィドルを作ることができますか? – SivaRajini

+0

@SivaRajini、最後のバージョンを確認してください。 – developer033

答えて

0

使用$touched

  1. ng-touched:フィールドは、それは他に検証していきますをタッチした後、制御は、他の言葉で、ぼやけてきた

    <div style="padding-bottom:5px;" ng-if="dnaform.uEmail.$touched && dnaform.uEmail.$error.email" class="help-block">Invalid Email.</div> 
    

    ドキュメントからあなたがそれを望んでいないので、<input>に追加する必要があります:

ng-model-options="{ updateOn: 'blur' }" 

スニペット:複数のチェックhereについては

(function() { 
 
    'use strict'; 
 
    angular.module('app', []) 
 
    .controller('mainCtrl', function($scope) { 
 

 
    }) 
 
})();
<!DOCTYPE html> 
 
<html ng-app="app"> 
 

 
<head> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular.min.js"></script> 
 
</head> 
 

 
<body ng-controller="mainCtrl"> 
 
    <form name="dnaform" novalidate> 
 
    <div style="padding-bottom:5px" ng-show="dnaform.uEmail.$pristine || dnaform.uEmail.$valid">Active directory account </div> 
 
    <div style="padding-bottom:5px;" ng-show="dnaform.uEmail.$dirty && dnaform.uEmail.$error.required" class="help-block">Email is Required.</div> 
 
    <div style="padding-bottom:5px;" ng-if="dnaform.uEmail.$touched && dnaform.uEmail.$error.email" class="help-block">Invalid Email.</div> 
 
    <input type="email" name="uEmail" ng-model-options="{ updateOn: 'blur' }" class="form-control txtBoxEdit type7N" ng-model="useremail" required> 
 
</form> 
 
</body> 
 

 
</html>

私はそれが助けてくれることを願っています!

0

入力がぼやけたときに呼び出す関数をいくつか記述します。このFiddle

$scope.blurred = function() { 

    }; 

コールの入力がどのように `input`要素の上に` NG-blur`について

<input type="text" ng-blur="blurred(inputsData)" ng-model="inputsData"> 
関連する問題