date validations in angular js & jquery

I have used below datepicker to display dates both in start& end dates.how to do date validations in angular js .

1)end date should be greater than start date.how to disable dates in end date datepicker?
2)difference between the dates should be 30 days.user can take only select dates for 30 days.

var search = angular.module('search', ['ui.bootstrap']);


				search.directive('jqstartdatepicker', function () {
				return {
					restrict: 'A',
					require: 'ngModel',
					 link: function (scope, element, attrs, ngModelCtrl) {
						element.datepicker({
							dateFormat: 'mm/dd/yy',
							onSelect: function (date) {
								scope.startdate = date;
								scope.$apply();
							}
						});
					}
				};
			});
	
				search.directive('jqenddatepicker', function () {
			return {
				restrict: 'A',
				require: 'ngModel',
				 link: function (scope, element, attrs, ngModelCtrl) {
					element.datepicker({
						dateFormat: 'mm/dd/yy',
						onSelect: function (date) {
						scope.enddate = date;
							scope.$apply();
						}
					});
				}
			};
		});	

Open in new window

<html ng-app="search" style="overflow-x: hidden">
<head><meta charset="utf-8">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/jquery-ui.min.css">

   <script src="lib/jquery/jquery-2.1.4.min.js"></script>
   <script src="lib/jquery/jquery-ui.min.js"></script>

 <script src="lib/angular/angular.min.js"></script>
<title>Tower Search POC</title>

  <body ng-controller="searchCtrl">
   <form name="myForm">
      
  <div class="container-fluid">
   
	  <div >
	  	  
	   
	    <div class="row">
		   <div class="form-group col-xs-6">
				<div class="controls">
					 <div id="nav-search">
						&nbsp;&nbsp;&nbsp;&nbsp;<small><b>Start Date</small></b>&nbsp;<input id="date-picker-2" type="text"  placeholder="StartDt" ng-model="startdate"  jqstartdatepicker/>
					  
					</div>
				</div>
			<br/>
			<div class="controls">
				 <div id="nav-search">
				   &nbsp;&nbsp;&nbsp;&nbsp;<small><b>  End Date</small></b>&nbsp;&nbsp;<input type="text" placeholder="EndDt" ng-model="enddate" jqenddatepicker/>
				</div>
			</div>
		  </div>
	    </div>
	
	</div>
	
	</div>

 
  
  </form>
</body></html>

Open in new window

LVL 20
chaitu chaituAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sajayj2009Commented:
BigRatCommented:
The working fiddle doesn't get the error messages correct, when you correct your first choice after an error.

As always why reinvent the wheel? There are several date range controls available on GitHub, where you can chhose what options you want5. Here is just three

https://github.com/luisfarzati/ng-bs-daterangepicker
https://github.com/fragaria/angular-daterangepicker
http://ngmodules.org/modules/angular-date-range-picker

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Angular

From novice to tech pro — start learning today.