$(document).ready(function () {
    $("body").on("change blur", ".month", ChangeMon);
    function ChangeMon() {
        
            var month = $(".month").val();
            var fryear = $(".fryear").val();
            var toyear = $(".toyear").val();
            var date = new Date();
            if (month != '') {
                if (month <= 3) {
                    var fdate = [toyear, month, "01"].join("-");
                    var adate = new Date([toyear , month, "01"].join("-"));
                    var lastdate = new Date(toyear, adate.getMonth() + 1, 0);
                    var tdate = [toyear , month, ("0" + lastdate.getDate()).slice(-2)].join("-");
                } else {
                    var fdate = [ fryear, month, "01"].join("-");
                    var adate = new Date([fryear, month, "01"].join("-"));
                    var lastdate = new Date(fryear, adate.getMonth() + 1, 0);
                    var tdate = [fryear, month, ("0" + lastdate.getDate()).slice(-2)].join("-");
                }
                $(".fdate").val(fdate);
                $(".tdate").val(tdate);
            }
    }
});