EasyUI Forum
May 05, 2024, 12:37:26 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: min/max values in Datetimebox  (Read 9388 times)
A-K
Full Member
***
Posts: 122


View Profile WWW
« on: October 06, 2014, 03:27:14 AM »

Hey,
Is there an option for min and max values in datetimebox?
I need to disable the dates that are not between the min and max value.

all I could do is check the date entered in the onchange event and clean the value
if its not between the min/max, But this solution is not user friendly and requires unnecessary clicks from the user.

Thanks.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: October 07, 2014, 09:38:00 AM »

The alternative solution is to extend a validation type to constrain the date value range. Please refer to this document http://www.jeasyui.com/documentation/validatebox.php
Logged
A-K
Full Member
***
Posts: 122


View Profile WWW
« Reply #2 on: October 07, 2014, 09:49:05 AM »

Thanks for the replay,
About the validation, it will still show all the dates that are not in the range
which may confuse the user, also the validation would be active when the user pressed a value
and the panel is closed and only then the error will be shown, or I am missing something?

I really need to not allow the user select the dates that are outside of the range and it should be
easily understood for the user which dates are valid and which not. If you can show
a simple example of the validation it would really help.

Thanks.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #3 on: October 07, 2014, 06:33:33 PM »

The validator function of calendar can be used to determine if a calendar day can be selected. The code below shows how to check constraint on date range.
Code:
$('#dd').datebox({
min:'10/2/2014',
max:'10/7/2014',
onShowPanel:function(){
var opts = $(this).datebox('options');
$(this).datebox('calendar').calendar({
validator: function(date){
var min = opts.parser(opts.min);
var max = opts.parser(opts.max);
if (min <= date && date <= max){
return true;
} else {
return false;
}
}
});
}
})
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!