JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="app">
<div ng-controller="TestController">
<label for="endDate" class="control-label">Start Date:</label>
<div>
<input type="text" class="form-control" id="startDate" ng-model="startDate" />
</div>
<label for="text" class="control-label">End Date:</label>
<div>
<input type="date" class="form-control" id="endDate" ng-model="endDate" ng-change='checkErr(startDate,endDate)' />
</div> <span>{{errMessage}}</span>
</div>
</div>
JavaScript
var app = angular.module('app', [])
.controller('TestController', function ($scope) {
$scope.checkErr = function (startDate, endDate) {
$scope.errMessage = '';
$scope.curDate = new Date();
if (startDate < endDate) {
$scope.errMessage = 'End Date should be greate than start date';
return false;
}
if (new Date(startDate) < $scope.curDate) {
$scope.errMessage = 'Start date should not be before today.';
return false;
}
};
});