Ask user to Save before leaving asp.net page

Ask user to Save before leaving asp.net page

I have a lab report application built in ASP.Net with C#, with multiple pages in it. Each page can have 5 to 8 data entry sections, each with their own Save button. I am trying to make sure the user saves their entries before changing pages, going to a different site or closing the browser. I found this script, which almost works, but also fires whenever I select one of the Save buttons on the page, thus preventing the user from saving. I am very new to JQuery and need to know how to tell this script to ignore those buttons. Any suggestions?

var isDirty = false;
        var msg = 'You haven\'t saved your changes.';
        $(document).ready(function(){
            $(':input').change(function(){
                if(!isDirty){
                    isDirty = true;
                }
            });

            window.onbeforeunload = function(){
                if(isDirty){
                    return msg;
                }
            };
        });