开发者

Halting postback, manually executing

My main page is a registration form with a Model. When the user clicks the submit button, the model validates and posts. However, I am in need of a step in between that forces the user to agree to some terms and fine print.

Originally, I was thinking that I would carry the model into a second confirmation page and then move onto a third 开发者_JAVA百科ActionResult that saved the information.

Second, I thought of just hiding the main DIV and then showing a second DIV that the agreements "live" in and then post back. But I'm not sure how I would validate the model before showing the second DIV and THEN post the form.


Why not just include the fine print and terms (and corresponding checkbox) as part of the registration form? That's how it's done pretty much everywhere, isn't it?


<form id="myForm">
...
<input type="button" id="formSubmit">
</form>
<div id="agreement"></div>

<script>
$(document).ready(function(){
$("#agreement").hide();
}):

$("#formSubmit").click(function(){
$("#agreement").show();
//ur logic to check if the user agree or disagree
$.ajax({
type:POST,
data:"formdata"
url:"/your/url"
success:function(){

}


});
});
</script>


Why make an extra call to validate the model if the user might reject your terms and fine print. I think you should either do what @Daniel recommends or if you must do it this way, post your model, get the validation back, show your fine print and then post the form again to a different action to save.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜