EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: alphasil on February 09, 2015, 02:27:31 PM



Title: Datebox
Post by: alphasil on February 09, 2015, 02:27:31 PM
Hi

I have this datebox a function

Code:
<script type="text/javascript">
         $('#data').datebox({
         formatter: function(date){ return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();},
         parser: function(date){ return new Date(Date.parse(date.replace(/-/g,"/")));}
         });
      </script>

But i want this datebox only allow to select 5 days from today...i mean if today is 09/02/2015, the next date the user can pick is 14/02/2015

any help?

Thanks


Title: Re: Datebox
Post by: yamilbracho on February 09, 2015, 06:28:51 PM
You can add a validator to your datebox field...


Title: Re: Datebox
Post by: alphasil on February 10, 2015, 06:42:21 AM
How can i do this??
This is new for me


Title: Re: Datebox
Post by: yamilbracho on February 11, 2015, 07:36:31 PM
It could be something like Ñ
Code:
<script type="text/javascript">
         $('#data').datebox({
         formatter: function(date){ return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();},
         parser: function(date){ return new Date(Date.parse(date.replace(/-/g,"/")));}
validator: function(value, param) {
   console.log(value);
   var dateArr = value.split('-');
   var y =  parseInt(dateArr[0], 10);
   var m =  parseInt(dateArr[1], 10);
   var d =  parseInt(dateArr[2], 10);
   var myDate = new Date(y, m-1, d);
   
   // Here you can check if the date is in the range you mentioned.
   // returning true is if fine, false otherwise
}
 });
  </script>