var ageApp = angular.module("ageApp", []); //factory myAgeFunctions end.
ageApp.controller("ageController", ['$scope', function ($scope) {
$scope.today = new Date(); //gets todays dd/mm/yyyy
$scope.todayDate = new Date($scope.today).getDate(); //gets todays date
$scope.todayMonth = new Date($scope.today).getMonth() + 1; //gets todays month
$scope.todayYear = new Date($scope.today).getFullYear(); //gets todays year
//A year will be a leap year if it is divisible by 4 but not by 100. If a year is divisible by 4 and by 100, it is not a leap year unless it is also divisible by 400.
$scope.dobLeapYear = function () {
if ((($scope.dobYear) % 4) == 0 && (($scope.dobYear) % 100) != 0) {
if ($scope.dobMonth == 2) {
if ($scope.dobDate > 29) {
$scope.dobDate = "";
$scope.dobDateError = true;
} else { $scope.dobDateError = false; }
}
} else if ((($scope.dobYear) % 4) == 0 && (($scope.dobYear) % 100) == 0 && (($scope.dobYear) % 400 == 0)) {
if ($scope.dobMonth == 2) {
if ($scope.dobDate > 29) {
$scope.dobDate = "";
$scope.dobDateError = true;
} else { $scope.dobDateError = false; }
}
} else {
if ($scope.dobMonth == 2) {
if ($scope.dobDate > 28) {
$scope.dobDate = "";
$scope.dobDateError = true;
} else { $scope.dobDateError = false; }
}
}
}
$scope.todayLeapYear = function () {
if ((($scope.todayYear) % 4) == 0 && (($scope.todayYear) % 100) != 0) {
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.