PDA

View Full Version : Java Script help


ThePoor
01-23-2008, 02:38 PM
Hi All,

I need some help, the code below only works with IE,
It's a form validation, Please help so it's also work with Firefox. If some1 using firefox they can just click on the "Continue with Application" buttion and get the file.

Thank you,



var checkedBox = new Image();
blank = new Image();
checkedBox.src = 'Images\/termError.gif';
blank.src = 'Images\/termErrorBlank.gif';

function showImage(imagename, imageurl, errors) {
document[imagename].src = imageurl;
}

function validate()
{
if (!(document.form1.Checkbox.checked))
{
showImage("Box", "Images/termError.gif", true) // no semi-colon after this line!
event.returnValue=false;
}
else
{
showImage("Box", "Images/termErrorBlank.gif", false); // true = errors, false = no errors
event.returnValue=true;
}
}


<form name="form1" id="form1" method="get" action="SMSA Application.pdf" onClick="validate();">
<p>
<center>
</center>
<input type="checkbox" name="Checkbox" value="isChecked">

I have read and agree to <strong>SMSA</strong>'s terms.<br>
<img name="Box" src="Images/termErrorBlank.gif" width=245 height=15 border=0></p>
<p>
<input type="submit" name"submit" value="Continue with Application" onsubmit="return validate()" href="SMSA Application.pdf">
</p>
</form>


or http://www.sportandmedicalsciences.org/SMSA_Application.htm

Force Flow
01-23-2008, 09:59 PM
http://www.w3schools.com/js/js_form_validation.asp

Take a close look at that.

First, you need to change this line:
<form name="form1" id="form1" method="get" action="SMSA Application.pdf" onClick="validate();">

use onSubmit, not onClick.

In the validate() function, you need to to a return true; or a return false;. These tell the form whether or not they can proceed with the form action.


Those are just the obvious things that popped out at me. I didn't check the rest of the code to see if those changes were the only things preventing it from working correctly.