473,394 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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
4 1594
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: RelaxoRy | last post by:
Reposted (not sure if got sent) I have results being displayed each with its own checkbox name "selected" and value "id". When someone checks a checkbox, and then continues to page through...
3
by: Marc Castrechini | last post by:
I have a page that changes an <ASP:Checkbox value based on a user entered value in a textboxm using client side Javascript. After my submit is fired the value for the chkMyCB.checked does not get...
3
by: Benjamin Gavin | last post by:
Hi all, I recently stumbled upon a bug in the ASP.NET framework handling of ImageButton based postbacks. The issues derives from the fact that IE and Mozilla handle the case of a missing image...
5
by: Leo J. Hart IV | last post by:
Hello, I'm hoping someone can help me out. I was wondering if the Enabled property of a CheckBox or RadioButton server control is stored in the ViewState. If not, is there some way to to add...
3
by: TCORDON | last post by:
Why does the click event of an image button that submitts a form does not get fired when ENTER is pressend on a textbox of that form? How can I make this happen? Thanks
7
by: Ryan Ternier | last post by:
I have a check box on my page. When a user clicks this box I have a confirmation box come up. When the user clicks OK, true is returned, otherwise false. Now, when true is Returened, I want...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
34
by: clinttoris | last post by:
Hello Experts, I have been told to post this in the Javascript forum as I want to do this client side just before my form gets submitted. Once the user clicks the submit button a javascript...
29
by: Amer Neely | last post by:
I've got a dynamically built form with checkboxes for each element ( a list of file names in a directory). I need to grab only those checkboxes that are checked, so I can then delete those files. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.