admin管理员组文章数量:1292808
So I have a form with multiple buttons each which have a Request mapping in a controller.
So I want to stop double submission of the form, but I can't disable the button after clicking as the controller can't get the information it needs to knwo what to do. This is the error I get:
org.springframework.web.bind.UnsatisfiedServletRequestParameterException: Parameter conditions "update" OR "verify" OR "reject" OR "updateCard" OR "approve" OR "withdraw" OR "updateStatusToReject" OR "updateStatusToApprove" not met for actual request parameters:
So I feel making the button readonly after clicking would fix this issue.
I have tried this so far, but it still allows the double submission.
$('.sendButton').click(function(){
$(this).prop('readonly', true);
});
<c:if test="${requestForm.status == 'R'}">
<input type="submit" name="updateStatusToApprove" value="Update To Approved" tabindex="7"
class="sendButton" id="appealA"/>
</c:if>
<c:if test="${requestForm.status == 'A' || requestForm.status == 'AA'}">
<input type="submit" name="updateStatusToReject" value="Update To Rejected" tabindex="8"
class="sendButton" id="appealR"/>
Any ideas how to stop the double submission without actually disabling the button.
So I have a form with multiple buttons each which have a Request mapping in a controller.
So I want to stop double submission of the form, but I can't disable the button after clicking as the controller can't get the information it needs to knwo what to do. This is the error I get:
org.springframework.web.bind.UnsatisfiedServletRequestParameterException: Parameter conditions "update" OR "verify" OR "reject" OR "updateCard" OR "approve" OR "withdraw" OR "updateStatusToReject" OR "updateStatusToApprove" not met for actual request parameters:
So I feel making the button readonly after clicking would fix this issue.
I have tried this so far, but it still allows the double submission.
$('.sendButton').click(function(){
$(this).prop('readonly', true);
});
<c:if test="${requestForm.status == 'R'}">
<input type="submit" name="updateStatusToApprove" value="Update To Approved" tabindex="7"
class="sendButton" id="appealA"/>
</c:if>
<c:if test="${requestForm.status == 'A' || requestForm.status == 'AA'}">
<input type="submit" name="updateStatusToReject" value="Update To Rejected" tabindex="8"
class="sendButton" id="appealR"/>
Any ideas how to stop the double submission without actually disabling the button.
Share Improve this question asked Nov 21, 2017 at 12:34 BlawlessBlawless 1,2993 gold badges17 silver badges29 bronze badges 2- I think read-only means you are disabling button, and you can also do this by restricting the submission of your call untill your previous request won't get fulfilled first. – sumit chauhan Commented Nov 21, 2017 at 12:36
- Or you can keep the input type as button instead of submit and assign a handler that executes only once. – gurvinder372 Commented Nov 21, 2017 at 12:43
1 Answer
Reset to default 6Make your input of type button
and assign a click
handler that execute only once using one
$('.sendButton').one( "click", function(){
//submit the form
$(this).closest('form').submit();
});
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" name="updateStatusToReject" value="Update To Rejected" tabindex="8" class="sendButton" id="appealR"/>
本文标签: javascriptMake button readonly after clickingStack Overflow
版权声明:本文标题:javascript - Make button readonly after clicking - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741561127a2385452.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论