Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My script does nothing 1

Status
Not open for further replies.

RexJacobus

Programmer
Dec 10, 2001
47
NZ
I'm not strong with javascript. Most of the code I'm using is cut and paste from another form on the website that I didn't write. I can't figure out why nothing is happening. It's probably something obvious.

I'm simply trying to put a quick check on the email field to make sure it's not blank and has an @. I get no alert, no error, and no comments or photos get uploaded (whereas the non-javascript version works fine).

thanx

MY CODE:[\b]
Code:
<script LANGUAGE="JavaScript">
<!--
     var dataOK=false;

    //
    // Check form2 for valid registration information
    //
    function validateForm2( form2 ) {
	// alert("Validating Form2" );


	   if(isFieldBlank(form2.email)) {
            alert("\nThe email address is empty.");
            return false;
			}
		s = ""+form2.email.value
		form2.email.value = s.toLowerCase();
		if(!isValidEmail(form2.email)) {
            alert("\nInvalid email address.");
            return false;
		}

		return true;
    }

    function isFieldBlank( theField ) {
	//alert("Checking Lenth of Field:" + theField.value.length );
        return( theField.value.length == 0);
    }  
	

        //
        // Check for a valid email address (Does it contain a "@")
        //
    function isValidEmail(theField) {
         var foundSymbol = false;
         var len = theField.value.length;
         if (theField.value.substring(0,1) == "@") {
             return false;
         }
         if (theField.value.substring(len-1,len) == "@") {
             return false;
         }
         for(var i=1; i<theField.value.length; i++) {
             var ch = theField.value.substring(i,i+1);
             if (ch == "@")
                       foundSymbol=true;
               }
         return foundSymbol;
         }

    }

function tpopup(s)
{
	msg=window.open(s, "rblPopup", "scrollbars=no,status=no,toolbar=no,directories=no,menubar=no,location=no,resizable=yes,width=400,height=50");
}

//--></script>
[\code]
[b]...HTML STUFF...[\b]

<Form method="POST" enctype="multipart/form-data" action="/cgi-bin/BlogUpload.cgi" name="form2">

[b]...MORE HTML...[\b]
							<input type=hidden name=is_registration value=1><input TYPE="text" NAME="reg_email" VALUE="" SIZE=25 MAXLENGTH=40>
 
Sorry, I had left it out from when I was testing something else. But it still doesn't work.

The following function is immediately before function tpopup(s)
___________________

function checkForm2(form2)
{
// alert("Checking form2");
if( validateForm2( form2 ) )
{
//alert("Form2 OK");
form2.submit();
return true;
} else {
return false;
}

}
 
Here is the code in its entirety.

thank you,

--------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Play Palago - Palago Blog Upload</title>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
body {
background-color: #000000;
font-family: Tahoma;
color: #FFFFFF;
}
a:link {
color: #99ffff;
text-decoration: none;
}
a:visited {
color: #00ccff;
text-decoration: none;
}
a:hover {
color: red;
text-decoration: underline;
}
-->
</style>



<script LANGUAGE="JavaScript">
<!--
var dataOK=false;

//
// Check form2 for valid registration information
//
function validateForm2( form2 ) {
// alert("Validating Form2" );


if(isFieldBlank(form2.email)) {
alert("\nThe email address is empty.");
return false;
}
s = ""+form2.email.value
form2.email.value = s.toLowerCase();
if(!isValidEmail(form2.email)) {
alert("\nInvalid email address.");
return false;
}

return true;
}

function isFieldBlank( theField ) {
//alert("Checking Lenth of Field:" + theField.value.length );
return( theField.value.length == 0);
}

function isBoxEmpty(theField) {

var len = theField.value.length
if (len >0) {
alert("\nlen gt 0.");
return false;
}
if (len =0) {
alert("\nlen eq 0.");
return false;
}
}


function isFieldValid(theField) {
var valid = "abcdefghijklmnopqrstuvwxyz0123456789";
var len = theField.value.length;
if ( (len < 3) || (len > 10) ) {
return false;
}

//alert("Checking field of length " + theField.value.length );

for( i=0; i<theField.value.length; i++ ) {
c = theField.value.substring(i, i+1).toLowerCase();
//alert( "Checking " + c );
if( valid.indexOf(c, 0) == -1 ) {
//alert( "Invalid " + c );
return false;
}
}
return true;
}
//
// Check for a valid email address (Does it contain a "@")
//
function isValidEmail(theField) {
var foundSymbol = false;
var len = theField.value.length;
if (theField.value.substring(0,1) == "@") {
return false;
}
if (theField.value.substring(len-1,len) == "@") {
return false;
}
for(var i=1; i<theField.value.length; i++) {
var ch = theField.value.substring(i,i+1);
if (ch == "@")
foundSymbol=true;
}
return foundSymbol;
}

}

function tpopup(s)
{
msg=window.open(s, "rblPopup", "scrollbars=no,status=no,toolbar=no,directories=no,menubar=no,location=no,resizable=yes,width=400,height=50");
}

//--></script>




</head>
<div align="center">


<body>

<table width=750>
<tr>
<td width=750>

<div align="center">
<table width=600>
<tr>
<td><img src="./images/PalagoniaLogo623.png" width="623" height="87" style="margin-top:20px; margin-bottom:10"> <BR>

</td>

</tr>

<tr>
<td>
<div align="center">
<font size=7><b>A WORLD OF SHAPES</b></font><BR><BR><BR>
</div>
</td>
</tr>
</table>


</td>
</tr>
</table>

<table width="750">
<tr>
<td width="40"></td>
<td width=710>


<table width="700">
<tr>
<td></td>
<td>

<font size="5"><B>Add Your Creature!</b></font><br><br>
<font size="2">
Please fill out the form below and browse to the location of your creature photo to select it. Don't forget to give your creature a name! If you want to tell us how and when you found the creature use the comments box.



<BR><BR>
Click the "Send" button and your picture and comments will be added to the blog. Please do not post any pictures or comments that others may find offensive.
<br><br>
<Form method="POST" enctype="multipart/form-data" action="/cgi-bin/PalagoBlogUploadTest.cgi" name="form2">


<div align="left">
<table width=700 border=0>

<tr>
<td width=50><font size="2">
</td>
<td width=100><div align="left">
<BR><font size="2"><b>Your name:</b> &nbsp;&nbsp;<BR><BR>
</td>
<td width=80><div align="left">
<input name=userid type=text></div>
</td>
<td width=220><div align="right">
<BR><font size="2"><b>Name of your creature:</b> &nbsp;<BR><BR>
</td></div>
<td width=250>
<font size="2"><input name=title type=text>
</td>

</tr>

<tr>
<td width=50><font size="2">
</td>
<td width=100><div align="left">
<BR><font size="2"><b>Town:</b> &nbsp;&nbsp;<BR><BR>
</td>
<td width=80><div align="left">
<input name=town type=text></div>
</td>
<td width=220><div align="right">
<BR><font size="2"><b>Country:</b> &nbsp;<BR><BR>
</td></div>
<td width=250>
<font size="2"><input name=cnty type=text>
</td>

</tr>
<tr>
<td width=50><font size="2">
</td>

<td width=100><div align="left">
<BR><font size="2"><b>Number of Tiles:</b> &nbsp;
</td></div>
<td width=250>
<font size="2"><input name=numb type=text>
</td>
<td width=220><div align="right">
<BR><font size="2"><b>Email:</b> &nbsp;&nbsp; <BR> <font size=1>
(Email address will not be shown)</font>

</td>
<td width=80><div align="left">
<!-- <input name=email type=text>
-->

<input type=hidden name=is_registration value=1><input TYPE="text" NAME="reg_email" VALUE="" SIZE=25 MAXLENGTH=40>



</div>
</td>

</tr>


<tr>
<td width=50><font size="2"> <BR><BR><BR><BR>
</td>
<td width=80><font size="2">
<b>Photo: </b>
</td>
<td width=500 colspan=3>

<input name=upfile type=file SIZE=63>

</td>
</tr>

<tr>
<td width=50><font size="2">
</td>
<td width=650 colspan=4><BR><div align=left>
<font size="2"><B>Enter your comments here: &nbsp; </b><BR><BR>
</td>
</tr>

<tr>
<td width=50><font size="2"> &nbsp;<BR>
</td>
<td width=80></td>
<td width=570 colspan=3>


<textarea name=comments cols=58 rows=8 scrolling=no></textarea><BR>
</td>

</tr>
</table>

<table width=700>

<tr>
<td> <div align=right>

<br>


<script language=javascript>
document.writeln("<input TYPE=button NAME=name VALUE='Send Blog Entry!' onClick='checkForm2(this.form, this)'>");
</script>

<!--
<input type=submit value="Send Blog Entry"> <BR><BR>
-->
</font>

</td>
</tr>
<tr>
<td width=380>
<BR><BR><img src="./images/Mask.jpg" width="375" height="300" style="margin-right:15px; ">
</td>
<td width=320>


<br><br><b>PHOTO REQUIREMENTS</b>
<br><BR>
<font size="2">
The size of the image should be similar to the one shown here on the left (around 300 x 300 pixels).
<br><BR>
If it is too large,
please use image editing software to trim it before uploading.
<br><br>

<br><br><br><br><br><br><br><BR>
<i>Palago Mask</i>
<br><br>
</td>

</tr>

</table>
</div>

<br>
</table>

</td>
</tr>
</table>
</td>
</tr>
</table>




<table width=750>
<tr>
<td colspan="3"><img src="../gfx/trn_cnt_2col.gif" width="750" height="1"><BR><BR></td>
</tr>
<tr>
<td width=700>

</td>


</tr>
</table>


<table width="750"><tr><td align="center"><font size=2><br>© Copyright 2010, Colour of Strategy Ltd. All rights reserved.<br>
Last update: February, 2010 </font><br><br></td></tr></table>

</body>
</html>
 
Hi

RexJacobus said:
I get no alert, no error
FireFox Error Console said:
[COLOR=white red] - [/color] syntax error
[blue]file:///home/master/RexJacobus.htm[/blue]
[tt] [navy]}[/navy][/tt]
[green][tt]-----^[/tt][/green]
Line: 116​
So no error ?


Anyway, remove the closing brace ( } ) from line 116.
RexJacobus said:
Here is the code in its entirety.
FireFox Error Console said:
[COLOR=white red] - [/color] checkForm2 is not defined
[blue]file:///home/master/RexJacobus.htm[/blue]
Line: 1​
So the entire code ?


Anyway, add the code you posted on 18 Mar 10 22:54, uncomment the email [tt]input[/tt] in line 253 and will work.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top