View Full Version : how can i define the checkvalue on?
megha_3000
02-04-2012, 07:18 AM
i.e the form submit will be successful when the check-box is on. such as only when i am agree to the terms and conditions is checked.
ankush
02-04-2012, 08:42 AM
Show your code, you can do this easily through javascript Have you tried it yourself?
keyboard
02-04-2012, 09:07 AM
Here's a script that disables the submit button unless the checkbox is checked. You can probably adapt it to your needs. Can't remember were I found it...
NOTE: This is not secure. Someone with knowledge of javascript could easily undisable the submit button. If you want it to be secure, you will have to use a server side language.
<html>
<head>
<script>
var checkobj
function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}
</script>
</head>
<body>
<form>
<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)">I agree to the terms and conditions</a><br>
<input type="submit" name="submit" value="Register" disabled="true">
</form>
</body>
</html>
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.