Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 表单模型状态无效时加载微调器_Javascript_Css_Asp.net Mvc - Fatal编程技术网

Javascript 表单模型状态无效时加载微调器

Javascript 表单模型状态无效时加载微调器,javascript,css,asp.net-mvc,Javascript,Css,Asp.net Mvc,大家好 我有一个旋转器,工作得很好。当我单击submit按钮时,它会询问用户是否要提交,如果按OK,它会触发控制器中的ActionMethod,微调器会滚动 但是,如果模型状态无效,微调器将继续滚动,并且不允许编辑表单,除非刷新页面。任何解决这个问题的方法。代码如下: $('#submitbtn').click(function () { var x = confirm("Are you sure to Submit Transaction?"); //co

大家好

我有一个旋转器,工作得很好。当我单击submit按钮时,它会询问用户是否要提交,如果按OK,它会触发控制器中的ActionMethod,微调器会滚动

但是,如果模型状态无效,微调器将继续滚动,并且不允许编辑表单,除非刷新页面。任何解决这个问题的方法。代码如下:

 $('#submitbtn').click(function () {
        var x = confirm("Are you sure to Submit Transaction?"); //confirm text
            if (x == true) {  //checking whether user clicked ok or cancel
            $('.spinner').css('display', 'block');  //if clicked ok spinner shown)  
        } else {  //else if clicked cancel spinner is hidden
            $('.spinner').css('display', 'none');
            return false //stops further process
        }
    });

我希望如果modelstate无效,微调器应该停止滚动,以便允许更正。

如注释中所建议的,在采取任何操作之前,首先验证表单。验证表单将检查所有模型属性是否正确:

$('#submitbtn').click(function () {
  if ($("#frmNameHere").valid()) {  //I added this

    var x = confirm("Are you sure to Submit Transaction?"); //confirm text
        if (x == true) {  //checking whether user clicked ok or cancel
        $('.spinner').css('display', 'block');  //if clicked ok spinner shown)  
    } else {  //else if clicked cancel spinner is hidden
        $('.spinner').css('display', 'none');
        return false //stops further process
    }
  }
});

这回答了你的问题吗?非常感谢。我已经用这种方法解决了。我之所以接受,是因为其他人以后会有这个问题