Quantcast
Channel: Serif Software Forums (Closed) - WebPlus
Viewing all articles
Browse latest Browse all 4745

WebPlus X6: Restricting Date Choice in the Web Plus DatePicker

$
0
0
When you have installed your X6 datepicker on your page and selected your field and named it (id) eg: REQUIREDDATE

You can add the following script code block to the HTML of your page pasting it over the <!--Page End--> tag at the foot of the page.

Code:

<script type="text/javascript">
$(function() {
$.datepicker.setDefaults( $.datepicker.regional[ "en-GB" ] );
$( "#REQUIREDDATE" ).datepicker( $.datepicker.regional[ "en-GB" ] );
$( "#REQUIREDDATE" ).datepicker( "option", "dateFormat", "dd-mm-yy" );
$( "#REQUIREDDATE" ).datepicker( "option", "minDate", "7D" );
$( "#REQUIREDDATE" ).datepicker( "option", "maxDate", "1Y" );
$( "#REQUIREDDATE" ).datepicker( "option", "yearRange", "c-0:c+1" );
  });
</script>

Change the items in Blue: REQUIREDDATE is the ID you gave your text field. minDate is the minimum date you will accept, eg 7D is seven days in the future from now, -7D is 7 days in the past from now. Use M and Y similarly for months and years.

maxDate works the same way except it is the maximum date you will accept.

yearRange is the years that you will allow eg: c-0:c+1 is No years in the past and 1 year in the future.

Demo here: http://www.richosoft.co.uk/ultimate/datepicker1.html

Hope that helps someone

regards

Steve

Viewing all articles
Browse latest Browse all 4745

Trending Articles