View Full Version : Checkbox : Validate form

Finland Blue
09-06-2010, 07:53 AM
I have a form on my web site and have used Behaviours -> Validate form to put various conditions on the fields.

I cannot find conditions though for a checkbox.

Here is the submit form code as it stands now ... can I add something in there to make a tick in checkbox compulsory?

onsubmit="MM_validateForm('E Mail address field','','RisEmail','cardholder','','R','cardnumb er','','RisNum','securitycode','','RisNum','amount otbecharged','','R');return document.MM_returnValue">

09-06-2010, 08:05 AM
hers a snippet i found as an example if it helps

<script type="text/javascript">
function validate(form) {
// Checking if at least one period button is selected. Or not.
if (!document.form1.sex[0].checked && !document.form1.sex[1].checked){

alert("Please Select Sex");
return false;}

if(!document.form1.agree.checked){alert("Please check the terms and conditions");
return false; }

return true;

Finland Blue
09-06-2010, 08:19 AM
Thanks for that. I tried it (after changing the various sex references to the right names ;-)) ...... but it did not show any action at all. I put the script in the head, below that generated by the Dreamweaver behaviours .... perhaps the "on Submit" does not check more than one script?

09-06-2010, 08:23 AM
changing the various sex references

Yep, that sounds like one of Ed's posts :wink:

09-06-2010, 08:29 AM
Yep, that sounds like one of Ed's posts :wink:

The erotic coder! :)

09-06-2010, 09:13 AM
you would have t call the script on submit so modify this one to add rthe other elements or add this to your existing.
have you two been reading my mail :)