PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Execute a JS/jQuery function on focus

  1. I have some jQuery that I need to execute onFocus for the datepicker which will block out days.

    Here's the jQuery that I'm running on the page:

    <script>
    function disableDays(selector,days,min) {
        var $ = jQuery;    
        var daysToDisable = days; // [5, 6] // Sat & Sun   
    
        function disableSpecificWeekDays(date) {        
            var day = date.getDay();        
            for (i = 0; i < daysToDisable.length; i++) {          
                if ($.inArray(day, daysToDisable) != -1) {            
                    return [false];          
                }        
            }        
            return [true];      
        }
    
        $(selector).datepicker('option', 'beforeShowDay', disableSpecificWeekDays);
        $(selector).datepicker('option', 'minDate', min);
    }
    </script>

    I need to execute this function on focus for Field ID 75

    How do I add this to the datepicker input?
    onfocus='(disableDays('#input_2_75',[5,6],'+4d');):"

    Posted 11 years ago on Wednesday May 15, 2013 | Permalink
  2. Richard Vav
    Administrator

    Could you not use the jQuery focus method.

    Posted 11 years ago on Wednesday May 15, 2013 | Permalink
  3. Thanks Richard,

    I got it working...

    For anyone else.... Here's what I did...

    Script above and:

    <script>
    jQuery('#input_2_75').one('focus',function() {
      disableDays('#input_2_75',[0,6],'+4d')
    });
    </script>
    Posted 11 years ago on Wednesday May 15, 2013 | Permalink
  4. Richard Vav
    Administrator

    You're welcome

    Posted 11 years ago on Thursday May 16, 2013 | Permalink

This topic has been resolved and has been closed to new replies.