View Full Version : Form Validation - User clicking hyperlink

12-30-2005, 03:37 PM
Hey -

I am wondering how I can code a form I have to validate whether a user clicks a hyperlink or not. What I am shooting for is to have a "Download" link (i guess it can be looked at as a submit button) and thats it. I want to validate whether the user clicks this "Download" link. If he/she does, they should be brought to a thank you page, where the download will take place. If he/she does not click the link, it should return false.

Here is what i have for my code thus far.

<html xmlns="http://www.w3.org/1999/xhtml">
<title>Cadillac Surprise & Delight</title>


/* This is the function that opens the 'save as' dialogue box in IE. */
/* It appears to fail gracefully in mozilla-based browsers but hsa not */
/* been fully tested */

<script language="JavaScript">
function forceSaveAs (imagename){


<script language="JavaScript">
function checkform()
if (value of first field is or isn't something)
// something is wrong
alert('There is a problem with the first field');
return false;
else if (value of next field is or isn't something)
// something else is wrong
alert('There is a problem with...');
return false;
// If the script gets this far through all of your fields
// without problems, it's ok and you can submit the form

return true;


<form action="" onSubmit="return checkform()">
<div class="thumb_img"><img src="/images/US/en/cadillac_surprise/thumb.jpg" border="0"></div>
<div class="thumb_txt"><a href="thankyou.html" onClick= return false">Download</a></div>