freejs首页

日期时间选择器,支持选择时间段,指定日期内选择,从某个日期到其他日期

      
rome(input, {
  timeValidator: function (d) {
    var m = moment(d);
    var start = m.clone().hour(12).minute(59).second(59);
    var end = m.clone().hour(18).minute(0).second(1);
    return m.isAfter(start) && m.isBefore(end);
  }
});
      
    
Value: (choose)
      
<div id='parent'></div>
<div id='result'>(choose)</div>

rome(parent).on('data', function (value) {
  result.innerText = value;
});
      
    

2个输入框输入不同的日期,自动让右侧的输入框输入的日期必须大于左侧

      
rome(left, {
  dateValidator: rome.val.beforeEq(right)
});

rome(right, {
  dateValidator: rome.val.afterEq(left)
});
      
    

Inline? No problem!

      
rome(left, {
  dateValidator: rome.val.beforeEq(right)
});

rome(right, {
  dateValidator: rome.val.afterEq(left)
});
      
    

Specific dates? Use these shortcuts!

You can use moments, Date objects, or strings. You're allowed to specify a single date, a date range, an array of specific dates, an array of date ranges, or a combination of those.

Oh, you can also reference calendars. Then, the selected date in that calendar is excluded (or the only option) in the validated calendar.

      
rome(first, {
  dateValidator: rome.val.except('2014-08-01')
});

rome(second, {
  dateValidator: rome.val.except('2014-08-02', '2014-08-06')
});

rome(third, {
  dateValidator: rome.val.except(['2014-08-04', '2014-08-09'])
});

rome(fourth, {
  dateValidator: rome.val.except([
    ['2014-08-03', '2014-08-07'], '2014-08-15'
  ])
});

rome(fifth, {
  dateValidator: rome.val.only([
    ['2014-08-01', '2014-08-15'], '2014-08-22'
  ])
});

rome(sixth, {
  dateValidator: rome.val.except([second, fourth, '2014-08-15'])
});