提交按钮不始终发射
我有一个带有提交按钮的ASP.NET Core Razor表单。当用户单击“更新”时,表单调用JavaScript函数以提示用户确定要完成请求。该功能一直在起作用,但是从上周开始,尽管用户确认他们想完成请求,偶尔也不会保存该表格。
<div class="form-group">
<label asp-for="Requests.Complete" class="lblReq"></label>
<select id="isComplete" asp-for="Requests.Complete" class="inputReq switch-disable">
<option value="N">N</option>
<option value="Y">Y</option>
</select>
<span asp-validation-for="Requests.Complete" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Update" class="btn btn-primary" onclick="return CompleteOrNot()" />
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
<script type="text/javascript">
$(document).ready(function () {
function CompleteOrNot() {
var value = ($("#isComplete").val());
if (value == "Y")
{
var retVal = confirm("Are you sure you want to complete this request?");
window.history.go(-1);
if (retVal == true) {
return true;
}
}
}
}
如果用户想完成请求,则总是会出现提示,有时帖子会通过,而其他时间,它的作用似乎是用户对提示说不的(即使他们没有)。您对如何进行故障排除/纠正此问题有任何建议吗?
I have an asp.net core razor form with a submit button. When the user clicks 'Update', the form calls a JavaScript function to prompt the user if they are sure they want to complete the request. This functionality has been working, but starting last week, the form will occasionally not save despite the user confirming that they want to complete the request.
<div class="form-group">
<label asp-for="Requests.Complete" class="lblReq"></label>
<select id="isComplete" asp-for="Requests.Complete" class="inputReq switch-disable">
<option value="N">N</option>
<option value="Y">Y</option>
</select>
<span asp-validation-for="Requests.Complete" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Update" class="btn btn-primary" onclick="return CompleteOrNot()" />
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
<script type="text/javascript">
$(document).ready(function () {
function CompleteOrNot() {
var value = ($("#isComplete").val());
if (value == "Y")
{
var retVal = confirm("Are you sure you want to complete this request?");
window.history.go(-1);
if (retVal == true) {
return true;
}
}
}
}
The user always gets prompted if they want to complete the request and sometimes the post goes through and other times it acts as though the user said no to the prompt (even though they did not). Do you have any suggestions on how to troubleshoot/correct this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想在
retval
为true时提交表格,请尝试使用以下代码If you want to submit the form when
retVal
is true,try to use the following code