Skip to content

Commit

Permalink
Added start time validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ansiblegalaxy committed Apr 2, 2014
1 parent c29451b commit e10cca6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/angular-scheduler.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@
ng-model="schedulerStartHour" placeholder="HH24" min="0" max="23" data-zero-pad="2" required
ng-change="scheduleTimeChange" >
<span>:</span><input name="schedulerStartMinute" id="schedulerStartMinute" sch-spinner="scheduler_form" class="scheduler-time-spinner" ng-model="schedulerStartMinute" placeholder="MM" min="0" max="59" data-zero-pad="2" required ng-change="scheduleTimeChange" >
<span>:</span><input name="schedulerStartSecond" id="schedulerStartSecond" sch-spinner="scheduler_form" class="scheduler-time-spinner" ng-model="schedulerStartSecond" placeholder="SS" min="0" max="23" data-zero-pad="2" required ng-change="scheduleTimeChange" >
<span>:</span><input name="schedulerStartSecond" id="schedulerStartSecond" sch-spinner="scheduler_form" class="scheduler-time-spinner" ng-model="schedulerStartSecond" placeholder="SS" min="0" max="59" data-zero-pad="2" required ng-change="scheduleTimeChange" >
</div>
<div class="error" ng-show="scheduler_startTime_error">Time must be in HH24:MM:SS format</div>
</div>
</div>
</div>
Expand Down
11 changes: 8 additions & 3 deletions lib/angular-scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ angular.module('AngularScheduler', ['underscore'])
this.scope.scheduler_weekDays_error = true;
validity = false;
}
if (this.scope.schedulerStartHour < 0 || this.scope.schedulerStartMinute < 0 || scope.schedulerStartSecond < 0 ||
this.scope.schedulerStartHour > 23 || this.scope.schedulerStartMinute > 59 || scope.schedulerStartSecond > 59) {
this.scope.scheduler_startTime_error = true;
validity = false;
}
if (!this.scope.scheduler_form.schedulerName.$valid) {
// Make sure schedulerName requird error shows up
this.scope.scheduler_form.schedulerName.$dirty = true;
Expand Down Expand Up @@ -817,9 +822,9 @@ angular.module('AngularScheduler', ['underscore'])
defaultDateStr = defaultDate.getFullYear() + '-' + defaultMonth + '-' + defaultDay;
scope.schedulerName = '';
scope.weekDays = [];
scope.schedulerStartHour = 0;
scope.schedulerStartMinute = 0;
scope.schedulerStartSecond = 0;
scope.schedulerStartHour = '00';
scope.schedulerStartMinute = '00';
scope.schedulerStartSecond = '00';
scope.schedulerStartDt = defaultDateStr;
scope.schedulerFrequency = scope.frequencyOptions[0];
scope.schedulerShowEvery = false;
Expand Down
Loading

0 comments on commit e10cca6

Please sign in to comment.