Detect and capture calendar date change

Have been at it for a few hours, may be someone dealt with this.

Iā€™m trying to detect when the date has changed inside the calendar date picker window and also capture the input.

Have seen a few forum posts about how this can be done with text fields and dropdown menus and it works great, but for calendarā€™s itā€™s a different story. From what I understand it generates some kind of a js date object.

I tried including

                                            'displayParams' =>
                                                array (
                                                    'javascript' => 'onchange="checkStatusOption(this)"',
                                                ),

In the editviewdefs.php but once again this works for all fields except for ā€œdateā€.

My ā€œbeautifulā€ JS function below is as far as I could get with my non-existant JS skillsā€¦

Right now Iā€™m just waiting for any click to happen on the page and then I validate the before and after value of the calendar picker. Which is not ideal to say the least.

I have the following inside the editview file. Hope somone can recommend something better!


    function display() {

        parent::display();

		$js = <<<EOT
<script type="text/javascript" language="JavaScript">
        
        // Capture initial state
        calendar_before = document.getElementById("contract_date_c").value;
               
       // Wait for any click to take place anywhere on the screen
        $(document).click(function() {
            
            // Capture state after we clicked somewhere
            calendar_after = document.getElementById("contract_date_c").value;
            
            // Compare the before and after
            if(calendar_before != calendar_after) {
                
                // Change detected
                alert("Something's changed eh?" + calendar_before +" "+ calendar_after);
            }
            
            // Set the new state of the before_calendar
            calendar_before = document.getElementById("contract_date_c").value;

            
        });
                
    }
      
</script>
EOT;

// now I output the javascript
        echo $js;

    }

I am not sure I understand. Are you talking of the calendar in SuiteCRM or just a date (custom) field?

There is a big difference in how to deal with the problem!

Hi there

Sorry I mean a regular ā€˜dateā€™ field.