By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,432 Members | 790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,432 IT Pros & Developers. It's quick & easy.

One CheckBox. one ImageButton. Why I can't force the user to click the agreement before submit form?

P: n/a
Dear All,

<input type="checkbox" name="chkAgreement" value="0">I agree with the above
terms and conditions

<asp:ImageButton ID="ImgBtnSubmit" Runat="server" CausesValidation=True
ImageUrl="images/submit.gif" width="70" height="30"></asp:ImageButton>

There is one CheckBox and one ImageButton, Now the situation is , once I
click the ImageButton. The form submitted automatically.

But now my requirement is to force the user to click the agreement first.
And the submit the form.

Likes Hotmail. First to agree the agreement. And then submit. if not agree.
Then the form can't be action.

So, What can I do in here?

Thanks,

Benny Ng
May 23 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Make sure ImageButton's Enabled property is set to false at the beginning.
Then set the AutoPostBack property of the checkbox to true and write
server-side code that once checkbox is checked, ImageButton is enabled. I
think this is a simple solution. Otherwise you may need to write some
CustomValidator implementation supporting both client and server side
interaction.
"Benny Ng" <mi********@hotmail.com> wrote in message
news:ut**************@TK2MSFTNGP03.phx.gbl...
Dear All,

<input type="checkbox" name="chkAgreement" value="0">I agree with the
above terms and conditions

<asp:ImageButton ID="ImgBtnSubmit" Runat="server" CausesValidation=True
ImageUrl="images/submit.gif" width="70" height="30"></asp:ImageButton>

There is one CheckBox and one ImageButton, Now the situation is , once I
click the ImageButton. The form submitted automatically.

But now my requirement is to force the user to click the agreement first.
And the submit the form.

Likes Hotmail. First to agree the agreement. And then submit. if not
agree. Then the form can't be action.

So, What can I do in here?

Thanks,

Benny Ng

May 23 '06 #2

P: n/a
Add some javascript:

<scrip language="javascript">
<!--
function enablesubmit() {
if (document.getElementById("chkAgreement").checked == true)
{
document.getElementById("ImgBtnSubmit").disabled = false;
}else{
document.getElementById("btnActivate").disabled = true;
}
}
-->
</script>

Then add the following to the button:
<input type="checkbox" name="chkAgreement" value="0"
onclick="javascript:enablesubmit();">I agree with the above
terms and conditions

If your submit button is initially disabled then this should do what you
need, but it will save you a postback.

HTH
"Benny Ng" <mi********@hotmail.com> wrote in message
news:ut**************@TK2MSFTNGP03.phx.gbl...
Dear All,

<input type="checkbox" name="chkAgreement" value="0">I agree with the
above terms and conditions

<asp:ImageButton ID="ImgBtnSubmit" Runat="server" CausesValidation=True
ImageUrl="images/submit.gif" width="70" height="30"></asp:ImageButton>

There is one CheckBox and one ImageButton, Now the situation is , once I
click the ImageButton. The form submitted automatically.

But now my requirement is to force the user to click the agreement first.
And the submit the form.

Likes Hotmail. First to agree the agreement. And then submit. if not
agree. Then the form can't be action.

So, What can I do in here?

Thanks,

Benny Ng

May 23 '06 #3

P: n/a
Thank you very much, Kerem, OZMNA.

Benny Ng

"Kerem OZMAN" <tm*@home.com> wrote in message
news:eH**************@TK2MSFTNGP03.phx.gbl...
Make sure ImageButton's Enabled property is set to false at the beginning.
Then set the AutoPostBack property of the checkbox to true and write
server-side code that once checkbox is checked, ImageButton is enabled. I
think this is a simple solution. Otherwise you may need to write some
CustomValidator implementation supporting both client and server side
interaction.
"Benny Ng" <mi********@hotmail.com> wrote in message
news:ut**************@TK2MSFTNGP03.phx.gbl...
Dear All,

<input type="checkbox" name="chkAgreement" value="0">I agree with the
above terms and conditions

<asp:ImageButton ID="ImgBtnSubmit" Runat="server" CausesValidation=True
ImageUrl="images/submit.gif" width="70" height="30"></asp:ImageButton>

There is one CheckBox and one ImageButton, Now the situation is , once I
click the ImageButton. The form submitted automatically.

But now my requirement is to force the user to click the agreement first.
And the submit the form.

Likes Hotmail. First to agree the agreement. And then submit. if not
agree. Then the form can't be action.

So, What can I do in here?

Thanks,

Benny Ng


May 23 '06 #4

P: n/a
Dear Stuart Irving,

It's really working!!! It should be used "getElementById" function to
make the detection.

Thank you very much!

Benny Ng

"Stuart Irving" <sp**@stuartirving.net> wrote in message
news:e6**************@TK2MSFTNGP02.phx.gbl...
Add some javascript:

<scrip language="javascript">
<!--
function enablesubmit() {
if (document.getElementById("chkAgreement").checked == true)
{
document.getElementById("ImgBtnSubmit").disabled = false;
}else{
document.getElementById("btnActivate").disabled = true;
}
}
-->
</script>

Then add the following to the button:
<input type="checkbox" name="chkAgreement" value="0"
onclick="javascript:enablesubmit();">I agree with the above
terms and conditions

If your submit button is initially disabled then this should do what you
need, but it will save you a postback.

HTH
"Benny Ng" <mi********@hotmail.com> wrote in message
news:ut**************@TK2MSFTNGP03.phx.gbl...
Dear All,

<input type="checkbox" name="chkAgreement" value="0">I agree with the
above terms and conditions

<asp:ImageButton ID="ImgBtnSubmit" Runat="server" CausesValidation=True
ImageUrl="images/submit.gif" width="70" height="30"></asp:ImageButton>

There is one CheckBox and one ImageButton, Now the situation is , once I
click the ImageButton. The form submitted automatically.

But now my requirement is to force the user to click the agreement first.
And the submit the form.

Likes Hotmail. First to agree the agreement. And then submit. if not
agree. Then the form can't be action.

So, What can I do in here?

Thanks,

Benny Ng


May 23 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.