且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在提交表单并重新加载页面后,使用jquery显示通知?

更新时间:2022-12-07 08:21:09

(this).val()。substr(


(this)。 val()。indexOf( - )+ 1);

if(last.length == 4){

var move =

>

(本).VAL()。SUBSTR(

I know that using .submit will trigger an event when the submit button is clicked. But I would like to trigger the event when the submit button have been clicked and the page reloaded (I think every page reloads after a form have been submitted).

I have this form

@using (Html.BeginForm("Feedback", "Home", FormMethod.Post))
                    {
                        @Html.ValidationSummary()

@Html.ValidationSummary("", new {@class = "text-danger"})
                        <div class="form-group">
                            @Html.LabelFor(m => m.Cell, new {@class = "col-md-2 control-label"})
                            <div class="col-md-10">
                                @Html.EditorFor(m => m.Cell, new {htmlAttributes = new {@class = "form-control", placeholder = "Phone Number", type = "text"}})
                            </div>
                        </div>
<div class="col-sm-6 col-sm-offset-3">
                            <div class="btn-toolbar">
                                <button class="btn-raised btn-success btn">
                                    Submit
                                    <div class="ripple-container"></div>
                                </button>
                                <button class="btn btn-default">Cancel</button>
                            </div>
                        </div>
}



What I have tried:

<script>
jQuery(document)
.ready(function() {

jQuery("#Cell").inputmask("099 999 9999");

jQuery("#Cell")
.on("blur",
function() {
var last = $(this).val().substr($(this).val().indexOf("-") + 1);
if (last.length == 4) {
var move = $(this).val().substr($(this).val().indexOf("-") - 1, 1);
var lastfour = move + last;
var first = $(this).val().substr(0, 9);
$(this).val(first + '-' + lastfour);
}
});

// check if user just submitted this page
var justSubmitted = $.cookie('just_submitted');
if (justSubmitted) {
$("#feedback").show();
// delete the cookie
$.cookie('just_submitted', null);
}

// submited
$("form")
.submit(function() {
// create a cookie, then let it submit normally
$.cookie('just_submitted', 'true');
});


});


</script>

(this).val().substr(


(this).val().indexOf("-") + 1);
if (last.length == 4) {
var move =


(this).val().substr(