Click to See Complete Forum and Search --> : What object is required?


Tasmanian Devil
06-22-2003, 08:14 AM
What did I do to this script?

<head>
<title>New User Login Screen</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript">
function validatePwd() {
var invalid = " "; // Invalid character is a space
var minLength = 4; // Minimum length
var pw1 = document.myForm.password.value;
var pw2 = document.myForm.password2.value;
// check for a value in both fields.
if (pw1 == '' || pw2 == '') {
alert('Please enter your password twice.');
return false;
}
// check for minimum length
if (document.myForm.password.value.length < minLength) {
alert('Your password must be at least ' + minLength + ' characters long. Try again.');
return false;
}
// check for spaces
if (document.myForm.password.value.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed.");
return false;
}
else {
if (pw1 != pw2) {
alert ("You did not enter the same password twice. Please re-enter your password.");
return false;
}
else {
alert('Thank you.');
return true;
}
}
}
</script>

</head>

<body bgcolor="#FFFFFF" text="#000000" background="clouds.jpg">
<form name="myForm" method="post" action="cgi-t/form.cgi" onSubmit="onsubmit=onSubmit="return checkPw(this)">
<p align="center"><b><font size="+3">
<input type=hidden name=from value="New User Login@foxvalleynews.com">
</p>

<table width="473" border="0" align="left">
<tr>
<td width="26%">First Name:*</td>
<td width="74%">
<input type="text" name="First Name:">
</td>
</tr>
<tr>
<td width="26%" height="22">Last Name:*</td>
<td width="74%" height="22">
<input type="text" name="Last Name:">
</td>
</tr>
<tr>
<td height="-4" width="26%">Address:*</td>
<td height="9" width="74%">
<input type="text" name="Address:">
</td>
</tr>
<tr>
<td height="-2" width="26%">Apartment:</td>
<td height="9" width="74%">
<input type="text" name="Apart:">
</td>
</tr>
<tr>
<td height="-1" width="26%">City:*</td>
<td height="20" width="74%">
<input type="text" name="City:">
</td>
</tr>
<tr>
<td height="-1" width="26%">State:</td>
<td height="20" width="74%">
<input type='text' class='txt' name='State:' value='Wisconsin' onFocus='this.blur()' size=20>
</td>
</tr>
<tr>
<td height="-4" width="26%">ZIP:*</td>
<td height="9" width="74%">
<input type="text" name="Zip:">
</td>
</tr>
<tr>
<td height="-2" width="26%">Email:*</td>
<td height="9" width="74%">
<input type="text" name="Email:">
</td>
</tr>
<tr>
<td height="-2" width="26%">Home Phone:*</td>
<td height="20" width="74%">
<input type="text" name="Home Phone:">
</td>
</tr>
<tr>
<td height="-2" width="26%">Work Phone:</td>
<td height="20" width="74%">
<input type="text" name="Work Phone:">
</td>
</tr>
<tr>
<td height="-1" width="26%">Password:*</td>
<td height="20" width="74%">
<input type=password name=password maxlength=12>
</td>
</tr>
<tr>
<td height="-3" width="26%">Verify Password:*</td>
<td height="9" width="74%">
<input type=password name=password2 maxlength=12>
</td>
</tr>
<tr>
<td height="15" width="26%">Secret Question:</td>
<td height="15" width="74%">
<select name="Secret Question">
<option value="Birth Place">Birth Place</option>
<option value="Mother's Maiden Name">Mother's Maiden Name</option>
<option value="Pet Name">Pet's Name</option>
</select>
</td>
</tr>
<tr>
<td height="-4" width="26%">Secret Answer:*</td>
<td height="3" width="74%">
<input type="text" name="Secret Answer">
</td>
</tr>
<tr>
<td height="-2" width="26%">&nbsp;</td>
<td height="4" width="74%">&nbsp;</td>
</tr>
<tr>
<td height="-1" colspan="2">* = Required <br>
You will be receiving an email within 2 - 3 business days confirming your
new login setup. After you login, you can update your information or can
have us stop your paper if your going on vacation.</td>
</tr>
<tr>
<td height="-1" width="24%">&nbsp;</td>
<td height="20" width="76%">&nbsp;</td>
</tr>
<tr>
<td height="20" colspan="2">
<input type=button onclick="this.form.submit(); self.close()" value="Submit">
</td>
</tr>
</table>
<div align="left"></div>
<p align="left">&nbsp;</p>
<p>&nbsp;</p>
</form>

<p>&nbsp;</p>
<p>&nbsp;</p>
</body>

This form just submits and does not check for the passwords to match.

Thanks
Devil

SlankenOgen
06-22-2003, 08:38 AM
<input type=button onclick="this.form.submit(); validatePwd(); self.close()" value="Submit">

you need to call the validatePwd function.

~mgb

Tasmanian Devil
06-22-2003, 08:46 AM
That worked except when the passwords are not 4 characters long or do not match it does not stop submitting the form and gives you a chance to fix the problem.

Thanks
Devil

Tasmanian Devil
06-22-2003, 08:48 AM
That worked except when the passwords are not 4 characters long or do not match it does not stop submitting the form and gives you a chance to fix the problem.

Thanks
Devil

Tasmanian Devil
06-22-2003, 09:36 AM
Line 240 Character 3 - what object is required?

<html>
<head>
<title>Fox Valley Newspapers</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#CCCCCC" text="#000000" bgproperties="fixed" background="http://216.104.190.167/clouds.jpg" link="#0000FF" vlink="#0000FF" alink="#FF0000" class="body">
<p>
<style type="text/css">
body { background-color:#ffcc77; font-family:"Verdana", sans-serif; font-size:13px; font-weight:bold;}
a.links{ font-family:"Verdana", sans-serif; font-size:13px; line-height:20px; color:black; text-decoration:none; font-weight:bold;}
a.links:active { color:black; }
a.links:hover { color:black; }
</style>
<script language="javascript" type="text/javascript">

function enHex(aDigit)
{

return("0123456789ABCDEF".substring(aDigit, aDigit+1))

}

function deHex(aDigit)

{

return("0123456789ABCDEF".indexOf(aDigit))

}

// Convert a 24bit number to hex

function toHex(n)

{

return (enHex((0xf00000 & n) >> 20) +

enHex((0x0f0000 & n) >> 16) +

enHex((0x00f000 & n) >> 12) +

enHex((0x000f00 & n) >> 8) +

enHex((0x0000f0 & n) >> 4) +

enHex((0x00000f & n) >> 0))

}

// Convert a six character hex to decimal

function toDecimal(hexNum)

{

var tmp = ""+hexNum.toUpperCase()

while (tmp.length < 6) tmp = "0"+tmp



return ((deHex(tmp.substring(0,1)) << 20) +

(deHex(tmp.substring(1,2)) << 16) +

(deHex(tmp.substring(2,3)) << 12) +

(deHex(tmp.substring(3,4)) << 8) +

(deHex(tmp.substring(4,5)) << 4) +

(deHex(tmp.substring(5,6))))

}



///////////////////Shimmering Links/////////////////////

//global variables

var hoverColour

var numLinks;

var rate;

var numFadeLevels;

var bgR;

var bgG;

var bgB;

var currR;

var currG;

var currB;

var count;

var fadeOut;

var continuous;

var newColour;

var tID;

var redInterval;

var greenInterval;

var blueInterval;

function initLinks(mouseOverColour, numberOfLinks, fadeOutColour)

{

hoverColour = mouseOverColour;

numLinks = numberOfLinks;

rate = 5;

numFadeLevels = 30;

function initArray(theArray, length, val)

{

for(i=0;i<length;i++)

{

theArray[i] = val;

}

}

bgR = '0000' + fadeOutColour.substring(1,3)

bgG = '0000' + fadeOutColour.substring(3,5)

bgB = '0000' + fadeOutColour.substring(5,7)

currR = new Array(numLinks);

currG = new Array(numLinks);

currB = new Array(numLinks);

count = new Array(numLinks);

fadeOut = new Array(numLinks);

continuous = new Array(numLinks);

newColour = new Array(numLinks);

tID = new Array(numLinks);

redInterval = toDecimal(bgR) / numFadeLevels;

greenInterval = toDecimal(bgG) / numFadeLevels;

blueInterval = toDecimal(bgB) / numFadeLevels;

initArray(currR,numLinks,0);

initArray(currG,numLinks,0);

initArray(currB,numLinks,0);

initArray(count,numLinks,0);

initArray(fadeOut,numLinks,true);

initArray(continuous,numLinks,true);

}

function startFade(id)

{

if(fadeOut[id] == true)

{ /*move colour towards background colour (increment)*/

currR[id] += redInterval;

currG[id] += greenInterval;

currB[id] += blueInterval;

newColour[id] = '#' + (toHex(currR[id])).substring(4,6) + (toHex(currG[id])).substring(4,6) + (toHex(currB[id])).substring(4,6);

if(++count[id] == numFadeLevels)

{

fadeOut[id] = false;

}

}

else

{

currR[id] -= redInterval;

currG[id] -= greenInterval;

currB[id] -= blueInterval;

newColour[id] = '#' + (toHex(currR[id])).substring(4,6) + (toHex(currG[id])).substring(4,6) + (toHex(currB[id])).substring(4,6);

if(--count[id] == 0)

{

fadeOut[id] = true;

}

}

if(continuous[id] == true)

{

document.getElementById(id).style.color = newColour[id];
}

else

{

document.getElementById(id).style.color = hoverColour;

}

clearTimeout(tID[id]);

tID[id]=setTimeout('startFade(' + id + ')', rate);

}

function continueFade(id)

{

continuous[id] = true;

}

function stopFade(id)

{

continuous[id] = false;

}

function StartTimers()

{ //set up an initial set of timers to start the shimmering effect

for(id=0; id<numLinks; id++)

{

t=setTimeout('startFade(' + id + ')', id*50);

}

}

//format = initLinks('mouse-over colour', 'number of links', 'fade-out colour')

initLinks('red', 4, '#FFCC77');

</script>
Buy A Paper On The Road<br>
<br>
<a class="links" id="0" onmouseover="stopFade('0');" onmouseout="continueFade('0');" href="http://fvnps.com/contact us.html" target="mainFrame">Contact
Us</a><br>
<br>
<a class="links" id="1" onmouseover="stopFade('1');" onmouseout="continueFade('1');" href="http://fvnps.com" target="_top">Fvnps.com</a><br>
<br>
<a class="links" id="2" onmouseover="stopFade('2');" onmouseout="continueFade('2');" href="http://fvnps.com/login.html" target="mainFrame">Jobs</a><br>
<br>
<a class="links" id="2" onmouseover="stopFade('3');" onmouseout="continueFade('3');" href="http://fvnps.com/login.html" target="mainFrame">Login</a>
<br>
</p>
<p>Moving
<script language="javascript" type="text/javascript">
setTimeout('StartTimers()', 1000); //initial 1 second delay to allow page to load and ensure smooth shimmering
</script>
</p>
</body>
</html>

Thanks Again
Devil

P.S. Thanks to you Dave on my last question

Tasmanian Devil
06-22-2003, 10:08 AM
Dave~
Line 240 goes as: document.getElementById(id).style.color = newColour[id];

Thanks Dave
Devil

P.S. I was wondering is it possible to do everything that javascript does but on a server side?

Tasmanian Devil
06-22-2003, 10:20 AM
Dave~
I do not know what I did but I fixed it. Thanks for your help though
Thanks Again
Devil