EasyUI Forum
May 16, 2024, 08:37:10 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Datebox  (Read 5561 times)
alphasil
Guest
« 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
Logged
yamilbracho
Jr. Member
**
Posts: 64


View Profile Email
« Reply #1 on: February 09, 2015, 06:28:51 PM »

You can add a validator to your datebox field...
Logged
alphasil
Guest
« Reply #2 on: February 10, 2015, 06:42:21 AM »

How can i do this??
This is new for me
Logged
yamilbracho
Jr. Member
**
Posts: 64


View Profile Email
« Reply #3 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>
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!