PDA

View Full Version : function and window.stop() help



Illkillutill
06-02-2010, 05:28 PM
Check out this page: http://andclan.forumotion.net/Application-Armed-N-Dangerous-h3.htm

My problem is the "I have read and Agree to the ToS" checkbox. It's supposed to be checked when they submit the app. If it's not checked, i want it to say, you haven't checked it and allow them to check it. It says that, but then it continues to the next page, which is what i'm trying to prevent with the window.stop() and document.execCommand('Stop').

What do I need to do?

This is the code stuff:

Page code:

<style type="text/css">
html, body {
height: 100%;
}

fieldset
{
border: 1px solid #000000;
}
</style>

<script language=javascript>
function validate(chk){
if (chk.checked == 1)
return true;
{
alert("You didn't agree to the ToS.");
window.stop();
document.execCommand('Stop')
}
}
</script>



<html>
<body>


<form method="post" action="http://www.emailmeform.com/fid.php?formid=422128" enctype="multipart/form-data" accept-charset="UTF-8"><fieldset style="border-color: orange;"><legend> Armed 'N Dangerous Application:</legend><center><table cellpadding="2" cellspacing="0" border="0" bgcolor="#111111"><tr><td><font face="Verdana" size="2" color="#FF9900"></font> <div style="" id="mainmsg"> </div></td></tr></table><br><table cellpadding="2" cellspacing="0" border="0" bgcolor="#111111"><tr valign="top"> <td nowrap><font face="Verdana" size="2" color="#FF9900">Game Name</font></td> <td><input type="text" name="FieldData0" size="30"> </td></tr><tr valign="top"> <td nowrap><font face="Verdana" size="2" color="#FF9900">Game combat level or rank</font></td> <td><input type="text" name="FieldData1" size="30"> </td></tr><tr valign="top"> <td nowrap><font face="Verdana" size="2" color="#FF9900">Will you post on the forums often?</font></td> <td><select name="FieldData2"><option value="Yes">Yes</option><option value="No">No</option></select> </td></tr><tr valign="top"> <td nowrap><font face="Verdana" size="2" color="#FF9900">Comments</font></td> <td><textarea name="FieldData3" cols="60" rows="10"></textarea><br> </td></tr><tr> <td colspan="2"><table cellpadding=5 cellspacing=0 bgcolor="#111111" width="100%"><tr bgcolor="#AAD6AA"><td class="label" colspan="2"><font color="#FFFFFF" face="Verdana" size="2"><b>Image Verification</b></font></td></tr><tr><td class="captcha" style="padding: 2px;" width="10"><img src="http://www.emailmeform.com/turing.php" id="captcha"></td><td class="field" valign="top"><div><font color="#FF9900">Please enter the text from the image</font>:<br><input type="text" name="Turing" value="" maxlength="100" size="10"> [ <a href="#" onclick=" document.getElementById('captcha').src = document.getElementById('captcha').src + '?' + (new Date()).getMilliseconds()">Refresh Image</a> ] [ <a href="http://www.emailmeform.com/?v=turing&pt=popup" onClick="window.open('http://www.emailmeform.com/?v=turing&pt=popup','_blank','width=400, height=500, left=' + (screen.width-450) + ', top=100');return false;">What's This?</a> ]</div></td></tr></table></td></tr><tr> <td><div style="position: absolute; left: 16px; width:100px;" id="p"><a href="http://www.contactmeform.com">form</a></div><br><input type=checkbox name=chk1> I have read and Agree to the ToS.<br><script language="JavaScript"><!-- var left = document.getElementById("p").style.left ; var top = document.getElementById("p").style.top ; document.write("<div style=\"position: absolute; top:" + top + "; left: " + left + "; background-color: #FFFFFF; display:block; width:100px; height: 20px;\"> </div>")//--></script> </td> <td align="left"><input type="text" name="hida2" value="" maxlength="100" size="3" style="display : none;"><input type="submit" class="btn" value="Send Application" name="Submit" onclick="return validate(chk1);"> <input type="reset" class="btn" value=" Clear Application " name="Clear"></td></tr><tr><td colspan=2 align="center"><br></td></tr></table></center></form></fieldset>


</body>
</html>


problem code:


<script language=javascript>
function validate(chk){
if (chk.checked == 1)
return true;
{
alert("You didn't agree to the ToS.");
window.stop();
document.execCommand('Stop')
}
}
</script>

AND


<input type="submit" class="btn" value="Send Application" name="Submit" onclick="return validate(chk1);">

nielsie95
06-02-2010, 05:33 PM
Try the form onsubmit method instead of the onclick method on the button (return true if it should continue).

Illkillutill
06-02-2010, 05:55 PM
you rock nielsie! it worked

thanks