Angular:

http://angularjs.org/

by mrajcok

HTML

<div ng-controller="MyCtrl">
  <form name="form">
        <div ng-repeat="fruit in localFruits">
            {{fruit.name}}: 
            <input ng-model="fruit.cost" required-when-key="local" custom-required/> 
            bound value is: [{{fruit.cost}}]
        </div>
    </form>
</div>

JavaScript

var app = angular.module('myApp',[]);

app.directive('customRequired', function() {
  return {
      restrict: 'A',
      require: 'ngModel',
      link: function(scope, elem, attrs, ctrl) {
          console.log(attrs.requiredWhenKey);
      }
  };
});

function MyCtrl($scope) {
    $scope.localFruits = [
      {name: 'banana'},
  ];
}