RexJacobus
Programmer
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]
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>