Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'fieldData.FROM_TIME': function(keyToGetData){
- return validator(function(value, options, model) {
- let fromTime = value;
- let toTime = model.get(keyToGetData);
- if(fromTime){
- let fromHours = fromTime.hours;
- let fromMins = fromTime.minutes;
- // make validation only if toTime is there
- if(toTime){
- let toHours = toTime.hours;
- let toMins = toTime.minutes;
- if(fromHours > toHours || ( fromHours===toHours && fromMins > toMins) ){
- return 'From time must be earlier than To time.';
- }
- }
- return true;
- }
- return 'This field can not be blank';
- });
- },
- 'fieldData.TO_TIME': function(keyToGetData){
- return validator(function(value, options, model) {
- let fromTime = model.get(keyToGetData);
- let toTime = value;
- if(toTime){
- let toHours = toTime.hours;
- let toMins = toTime.minutes;
- // make validation only if fromTime is there
- if(fromTime){
- let fromHours = fromTime.hours;
- let fromMins = fromTime.minutes;
- if(fromHours > toHours || (fromHours===toHours && fromMins >= toMins) ){
- return 'To time must be later than From time.';
- }
- }
- return true;
- }
- return 'This field can not be blank';
- });
- }
Add Comment
Please, Sign In to add comment