Form method post and jquery/javascript code dosnt work on 1 single computer in all browsers

问题: I have a website coded in asp.net core 2.1. In one of the razor views I have 2 <input type="date">(a startdate and an enddate), a submit button and some jquery/javasc...

问题:

I have a website coded in asp.net core 2.1. In one of the razor views I have 2 <input type="date">(a startdate and an enddate), a submit button and some jquery/javascript code (to check that the enddate isn't before the startdate and the startdate isn't after current date and startdate isn't after enddate). This is all working in all browsers and on all computers as it should, EXCEPT ON 1 single computer.

The system that isnt working is running Windows 10 pro x64, and everything should be updated.

The exact same setup is on another laptop where it IS WORKING. Both laptops are part of same company so they are identical in manufacturer, OS and software. None of them are part of a Domain.

The page loads really fast, as if it was cached, but I cleared all browser data, and updates on code and html tags is displaying. I cant seem to pinpoint the problem. This is what I tried so far:

  • I tried on other computers on all browsers with the exact same setup (as far as I know
  • I tried Chrome, Firefox, Internet Explorer and Edge. Same result
  • I tried clearing browser data (everything)

*UPDATE**** I tried changing the default input date to Jquery datepicker. The same error persists. It defaults to 01 january 1901. Works everywhere else. This is only happening on 1 single computer :-( Picture of problem: https://imgur.com/vcu2Bq5.jpg ***UPDATE*

This is my code: HTML/Razor view

 <form method="post">
        <table>
            <tr>
                <td><label>Fra dato</label></td>
                <td><label>Til dato</label></td>
                <td></td>
            </tr>
            <tr>
                <td><input type="date" id="TB_StartDate" name="TB_StartDate" required value="@ViewBag.StartDate" /></td>
                <td><input type="date" id="TB_EndDate" name="TB_EndDate" required value="@ViewBag.EndDate" /></td>
                <td><input type="submit" name="BTN_ReloadDates" class="btn btn-primary" value="Hent ændringer" /></td>
            </tr>
            <tr>
                <td colspan="3"></td>
            </tr>
        </table>
    </form>
    <label class="label label-danger" style="font-size: large;" for="Datepick" id="L_Warning"></label>

JQuery

<script src="~/js/Jquery.min.js"></script>
<script src="~/js/moment.min.js"></script>
<script>

    $("#L_Warning").hide();


    $('#TB_StartDate').change(function () {
        $("#L_Warning").hide();
        var StartDate = $("#TB_StartDate").val();
        var EndDate = $("#TB_EndDate").val();
        var now = moment().format('YYYY-MM-DD');

        if (StartDate > now) {
            $("#TB_StartDate").val(now);
            $("#TB_EndDate").val(now);
            $("#L_Warning").show();
            $("#L_Warning").fadeOut().fadeIn().fadeOut().fadeIn().fadeOut().fadeIn().fadeOut().fadeIn();

            $("#L_Warning").text("Du kan ikke vælge en nyere dato end idag.");

        }
        else if (StartDate > EndDate) {
            $("#TB_EndDate").val(StartDate);
        }


    });

    $('#TB_EndDate').change(function () {
        $("#L_Warning").hide();
        var StartDate = $("#TB_StartDate").val();
        var EndDate = $("#TB_EndDate").val();
        var now = moment().format('YYYY-MM-DD');

        if (EndDate > now) {
            $("#TB_EndDate").val(now);
            $("#L_Warning").show();
            $("#L_Warning").fadeOut().fadeIn().fadeOut().fadeIn().fadeOut().fadeIn().fadeOut().fadeIn();

            $("#L_Warning").text("Du kan ikke vælge en nyere dato end idag.");

        }
        else if (EndDate < StartDate) {
            $("#TB_StartDate").val(EndDate);
        }


    });


</script>

回答1:

I SOLVED IT :-)

Turns out, the problem had something to do with the user on the system. (I forgot to remove some test code that messed up with that particular user).

  • 发表于 2019-01-18 17:35
  • 阅读 ( 192 )
  • 分类:网络文章

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除