Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body ng-app="Demo">
  <Br />
  <br />
  <div ng-controller="TestCtrl" >   
    <form name='yourForm' novalidate ng-submit="save(yourForm)">
        <label>Field 1</label>
        <input type="email" name="first" ng-model="fname"   ng-blur="displayData()">
        <br><br>
        <label>Field 2</label>
        <input type="text"   name="last" ng-model="lname"  ng-blur="displayData()">
        <button type="button">finish</button>
</form>
</div>
</body>
</html>
 
var app = angular.module('Demo', []);
app.controller('TestCtrl', function ($scope) {
    
  $scope.displayData = function(){
    
   var inp = document.getElementsByName('first')[0];
    
    if(inp.value != "test"){
       alert("Will focus because value is" + inp.value);
      inp.focus();
      return false;
    }
    return true;
  };
      
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers