| View previous topic :: View next topic |
| Author |
Message |
dodge-i
Joined: 31 May 2008 Posts: 1
|
Posted: Sat May 31, 2008 6:42 pm Post subject: Help with putting this form together |
|
|
I have this form and on it is a check box. The check
box will need to be check before the user can continue
on to the next page.
The submit button has an onclick event handler that will
run a javascript that will check to see if the check box
is checked. If it is not checked, a msg saying please
check the check box will be displayed next to the check
box.
I need help in setting up how I can run the javascript and
then submit the page to the server. Only when the checkbox
is checked will the submit button send data to the server. If
the check box is not checked and the user clicks submit, then
the javascript will be executed and no data will be sent yet. |
|
| Back to top |
|
 |
|
|
rangana 500+ Club

Joined: 27 Feb 2008 Posts: 718 Location: Cebu City Philippines
|
Posted: Mon Jun 02, 2008 4:07 am Post subject: Re: Help with putting this form together |
|
|
See if this basic example helps:
| Code: |
<script type="text/javascript">
function check()
{
var check1=document.getElementById('check1'),
check2=document.getElementById('check2'),
message=document.getElementById('message');
if(check1.checked!=true&&check2.checked!=true)
{
message.innerHTML='"My Message when checkboxes are not checked"';
return false;}
else return true;
}
</script>
<form name="#" action="http://www.google.com" onsubmit="return check()">
<input type="checkbox" id="check1"><label>Checkbox 1</label>
<input type="checkbox" id="check2"><label>Checkbox 1</label>
<span id="message"></span><br>
<input type="Submit" value="Submit">
</form>
|
|
|
| Back to top |
|
 |
|