• I am using cforms to create a registration form and one of the fields is a data picker. I would like to restrict the dates available in the date picker to not include weekends. I found the following jquery option to disable weekends

    $("#datepicker").datepicker({ beforeShowDay: $.datepicker.noWeekends });

    Since I dont want to modify the source code for cforms I would like to change the instance of datepicker after its been initialized by adding javascript to the page via the wordpress html editor with something like:

    <script type="text/javascript">// <![CDATA[
    $(".cf_date").datepicker('option', {beforeShowDay: noWeekends});
    // ]]></script>

    Can someone point out what I am doing wrong?

    Copied below is the javascript cforms generates:

    <script type="text/javascript">
    	var cfCAL={};
    	cfCAL.dateFormat = "mm/dd/yy";
    	cfCAL.dayNames = ["S","M","T","W","T","F","S"];
    	cfCAL.abbrDayNames = ["S","M","T","W","T","F","S"];
    	cfCAL.monthNames = ["January","February","March","April","May","June","July","August","September","October","November","December"];
    	cfCAL.abbrMonthNames = ["January","February","March","April","May","June","July","August","September","October","November","December"];
    	cfCAL.firstDayOfWeek = "0";
    	cfCAL.fullYearStart = "20";
    	cfCAL.TEXT_PREV_YEAR="";
    	cfCAL.TEXT_NEXT_YEAR="";
    	cfCAL.TEXT_PREV_MONTH="Previous Month";
    	cfCAL.TEXT_NEXT_MONTH="Next Month";
    	cfCAL.TEXT_CLOSE="Close";
    	cfCAL.TEXT_CHOOSE_DATE="Choose Date";
    	cfCAL.changeYear=false;
    	cfCAL.ROOT="https://www.dubhlinnpub.com/wp-content/plugins/cforms";
    
    	jQuery(function() {
    		if( 1||jQuery.datepicker ){
    			jQuery(".cf_date").datepicker({
    				"buttonImage": cfCAL.ROOT+"/js/calendar.gif", changeYear: cfCAL.changeYear, buttonImageOnly: true, buttonText: cfCAL.TEXT_CHOOSE_DATE, showOn: "both",
    				"dateFormat": cfCAL.dateFormat, "dayNamesMin": cfCAL.dayNames, "dayNamesShort": cfCAL.dayNames, "monthNames": cfCAL.monthNames, firstDay:cfCAL.firstDayOfWeek,
    				"nextText": cfCAL.TEXT_NEXT_MONTH, "prevText": cfCAL.TEXT_PREV_MONTH, "closeText": cfCAL.TEXT_CLOSE });
    		}
    	});
    </script>

    THANKS!

  • The topic ‘cforms remove weekends in datepicker’ is closed to new replies.