Hi guys,
I have got a prob of javascript form validation which just doesnt work
with my ASP code. Can any one help me out please.
Here is the code:
{////<<head>
<title>IIBO Submit Page</title>
</head>
<style type="text/css">
<!--
.myform {
font-size:10pt; color:Black; font-family:verdana,sans-serif;}
--></style>
<script language="javascript" type="text/javascript">
<!--
//Validating the form
function validate(){
if (document.form1.f_name.value.length < 1) {
alert("Please enter your first name.");
return false;
}
if (document.form1.s_name.value.length < 1) {
alert("Please enter your surname.");
return false;
}
if (document.form1.e_address.value.length < 1) {
alert("Please enter your first name.");
return false;
}
if (document.form1.f_name.value.length < 1) {
alert("Please enter your emailaddress.");
return false;
}
if (document.form1.tel_number.value.length < 1) {
alert("Please enter your telephone number.");
return false;
}
if (document.form1.emp_id.value.length < 1) {
alert("Please enter your employee ID.");
return false;
}
if (document.form1.title_suggestion.value.length < 1) {
alert("Please enter your suggestion title.");
return false;
}
if (document.form1.suggestion.value.length < 3) {
alert("Please enter your suggestion.");
return false;
}
return ture;
}
var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true:
false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true :
false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;
// resize fix for ns4
var origWidth, origHeight;
if (ns4) {
origWidth = window.innerWidth; origHeight = window.innerHeight;
window.onresize = function() { if (window.innerWidth !=
origWidth || window.innerHeight != origHeight) history.go(0); }
}
// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }
// settings for tooltip
// Do you want tip to move when mouse moves over link?
var tipFollowMouse= true;
// Be sure to set tipWidth wide enough for widest image
var tipWidth= 260;
var offX= 20; // how far from mouse to show tip
var offY= 12;
var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
var tipFontSize= "8pt";
// set default text color and background color for tooltip here
// individual tooltips can have their own (set in messages arrays)
// but don't have to
var tipFontColor= "#000000";
var tipBgColor= "#DDECFF";
var tipBorderColor= "#000080";
var tipBorderWidth= 3;
var tipBorderStyle= "ridge";
var tipPadding= 4;
// tooltip content goes here (image, description, optional bgColor,
optional textcolor)
var messages = new Array();
// multi-dimensional arrays containing:
// image and text for tooltip
// optional: bgColor and color to be sent to tooltip
messages[0] = new Array('clear.jpg','Email Address: Please enter
your email address into this field. Your email address will be used
to confirm your idea submission and updates to your
idea.',"#6699cc");
messages[1] = new Array('clear.jpg','Telephone Number: Please enter
your telephone number in this field. You may enter your internal
number e.g 143 2136, or your external number e.g. 020 704
32136',"#6699cc");
messages[2] = new Array('clear.jpg','Employee ID: Please enter your
employee number into this field. Your employee number is 7 digits
long e.g 1234567 and can be found on your pay slip. If you are
unsure of your employee ID please contact HR help desk on 143
2316','#6699cc');
messages[3] = new Array('clear.jpg','Job Title: Please enter your
job title, or what ever best describes your job role, into this
field.','#6699cc');
messages[4] = new Array('clear.jpg','Site: Please select, from the
drop down menu, the site at which you are primarily based. If your
location is not on the list please select other.','#6699cc');
messages[5] = new Array('clear.jpg','Employee Type: Please select,
from the drop down menu, your employee type. If you are unsure or
your employee type is not on the list please select
other.','#6699cc');
messages[6] = new Array('clear.jpg','Directorate: Please select,
from the drop down menu, your directorate. If you are unsure or your
directorate is not on the list please select other.','#6699cc');
messages[7] = new Array('clear.jpg','Suggestion Title: Please enter
a title for your suggestion. This may be a breif sentence to
summaries your suggestion','#6699cc');
messages[8] = new Array('clear.jpg','Suggestion: Please give a full
description of your suggestion. ','#6699cc');
messages[9] = new Array('clear.jpg','Estimated Cost Savings: Please
select, from the drop down menu, an estimate of how much your
suggestion will save in costs. If you are unsure please select Not
Sure. If it is not application, select Not Applicable. ','#6699cc');
// preload images that are to appear in tooltip
// from arrays above
if (document.images) {
var theImgs = new Array();
for (var i=0; i<messages.length; i++) {
theImgs[i] = new Image();
theImgs[i].src = messages[i][0];
}
}
// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// startStr goes before image, midStr goes between image and text
var startStr = '<table width="' + tipWidth + '"><tr><td
align="center" width="100%"><img src="';
var midStr = '" border="0"></td></tr><tr><td valign="top">';
var endStr = '</td></tr></table>';
////////////////////////////////////////////////////////////
// initTip - initialization for tooltip.
// Global variables for tooltip.
// Set styles for all but ns4.
// Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss, tipFrameStyle;
function initTip() {
if (nodyn) return;
tooltip = (ns4)? document.tipDiv.document: (ie4)?
document.all['tipDiv']: (ie5||ns5)?
document.getElementById('tipDiv'): null;
tipFrameStyle = (document.all)?document.all.tipFrame.style:
document.getElementById("tipFrame").style;
//alert use this on the next line for KOMSTA debugging RE
RRP0016
(tipFrameStyle)
tipcss = (ns4)? document.tipDiv: tooltip.style;
if (ie4||ie5||ns5) { // ns4 would lose all this on rewrites
tipcss.width = tipWidth+"px";
tipcss.fontFamily = tipFontFamily;
tipcss.fontSize = tipFontSize;
tipcss.color = tipFontColor;
tipcss.backgroundColor = tipBgColor;
tipcss.borderColor = tipBorderColor;
tipcss.borderWidth = tipBorderWidth+"px";
tipcss.padding = tipPadding+"px";
tipcss.borderStyle = tipBorderStyle;
}
if (tooltip&&tipFollowMouse) {
if (ns4) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = trackMouse;
}
}
window.onload = initTip;
/////////////////////////////////////////////////
// doTooltip function
// Assembles content for tooltip and writes
// it to tipDiv
/////////////////////////////////////////////////
var t1,t2; // for setTimeouts
var tipOn = false; // check if over tooltip link
function doTooltip(evt,num) {
if (!tooltip) return;
if (t1) clearTimeout(t1); if (t2) clearTimeout(t2);
tipOn = true;
// set colors if included in messages array
if (messages[num][2]) var curBgColor = messages[num][2];
else curBgColor = tipBgColor;
if (messages[num][3]) var curFontColor = messages[num][3];
else curFontColor = tipFontColor;
if (ns4) {
var tip = '<table bgcolor="' + tipBorderColor + '"
width="' + tipWidth + '" cellspacing="0" cellpadding="' +
tipBorderWidth + '" border="0"><tr><td><table bgcolor="' +
curBgColor + '" width="100%" cellspacing="0" cellpadding="' +
tipPadding + '" border="0"><tr><td>'+ startStr + messages[num][0] +
midStr + '<span style="font-family:' + tipFontFamily + ';
font-size:' + tipFontSize + '; color:' + curFontColor + ';">' +
messages[num][1] + '</span>' + endStr +
'</td></tr></table></td></tr></table>'; tooltip.write(tip);
tooltip.close();
} else if (ie4||ie5||ns5) {
var tip = startStr + messages[num][0] + midStr + '<span
style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize
+ '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' +
endStr;
tipcss.backgroundColor = curBgColor;
tooltip.innerHTML = tip;
}
if (!tipFollowMouse) positionTip(evt);
else
t1=setTimeout("tipcss.visibility='visible';tipFram eStyle.visibility=
'visible';",100);
}
var mouseX, mouseY;
function trackMouse(evt) {
mouseX = (ns4||ns5)? evt.pageX: window.event.clientX +
document.body.scrollLeft;
mouseY = (ns4||ns5)? evt.pageY: window.event.clientY +
document.body.scrollTop;
if (tipOn) positionTip(evt);
}
/////////////////////////////////////////////////////////////
// positionTip function
// If tipFollowMouse set false, so trackMouse function
// not being used, get position of mouseover event.
// Calculations use mouseover event position,
// offset amounts and tooltip width to position
// tooltip within window.
/////////////////////////////////////////////////////////////
function positionTip(evt) {
if (!tipFollowMouse) {
mouseX = (ns4||ns5)? evt.pageX: window.event.clientX +
document.body.scrollLeft;
mouseY = (ns4||ns5)? evt.pageY: window.event.clientY +
document.body.scrollTop;
}
// tooltip width and height
var tpWd = (ns4)? tooltip.width: (ie4||ie5)?
tooltip.clientWidth: tooltip.offsetWidth;
var tpHt = (ns4)? tooltip.height: (ie4||ie5)?
tooltip.clientHeight: tooltip.offsetHeight;
// document area in view (subtract scrollbar width for ns)
var winWd = (ns4||ns5)?
window.innerWidth-20+window.pageXOffset:
document.body.clientWidth+document.body.scrollLeft ;
var winHt = (ns4||ns5)?
window.innerHeight-20+window.pageYOffset:
document.body.clientHeight+document.body.scrollTop ;
// check mouse position against tip and window dimensions
// and position the tooltip
if ((mouseX+offX+tpWd)>winWd)
tipcss.left = (ns4)? mouseX-(tpWd+offX): mouseX-
(tpWd+offX)+"px";
else tipcss.left = (ns4)? mouseX+offX: mouseX+offX+"px";
if ((mouseY+offY+tpHt)>winHt)
tipcss.top = (ns4)? winHt-(tpHt+offY): winHt-(tpHt+offY)
+"px";
else tipcss.top = (ns4)? mouseY+offY: mouseY+offY+"px";
tipFrameStyle.width = tpWd+6;
tipFrameStyle.height = tpHt+6;
tipFrameStyle.left = tipcss.left;
tipFrameStyle.top = tipcss.top;
if (!tipFollowMouse)
t1=setTimeout("tipcss.visibility='visible';tipFram eStyle.visibility=
'visible'",100);
}
function hideTip() {
if (!tooltip) return;
t2=setTimeout("tipcss.visibility='hidden';tipFrame Style.visibility='
hidden'",100);
tipOn = false;
}
//-->
</script>
<body>
<form name="form1" method="post" action="confaddidea.asp"
onSubmit="return validate();">
<font face=Verdana size=2>
<i>Please note all fields marked with * are mandatory.</i>
<i>Click on the <img src="iicon.gif" alt="" width=16px height=16px>
icon for help with each field</i>
<BR><BR>
<table>
<TR>
<TD style="width=265px"> <font face=Verdana size=2>
* First Name :
<BR>
<input name="f_name" size=25 maxlenght=50
class="myform">
<img src="clear.jpg" border=0 width=23
height=20></a><br>
<BR>
* Surname Name :
<BR>
<input name="s_name" size=25 maxlenght=50
class="myform" >
<img src="clear.jpg" border=0 width=23
height=20></a><br>
<BR>
* Email Address:
<BR>
<input name="e_address" size=25
maxlenght=50 class="myform" >
<a href="#" onmouseover="doTooltip(event,0)"
onmouseout="hideTip()">
<img src="iicon.gif" border=0 width=16px
height=16px></a><br><BR>
* Telephone Number
<BR>
<input name="tel_number" size=25
maxlenght=50 class="myform" >
<a href="#"
onmouseover="doTooltip(event,1)" onmouseout="hideTip()">
<img src="iicon.gif" border=0 width=16px
height=16px></a><br>
<BR>
* Employee ID :
<BR>
<input name="emp_id" size=25 maxlenght=50
class="myform" >
<a href="#"
onmouseover="doTooltip(event,2)" onmouseout="hideTip()">
<img src="iicon.gif" border=0 width=16px
height=16px></a><br>
<br>
<BR>
</TD>
<TD style="width=275px" valign="top" align="left">
<font face=Verdana size=2>
Job title :
<BR>
<input name="job_title" style="width=235px"
maxlenght=50 class="myform" >
<a href="#"
onmouseover="doTooltip(event,3)" onmouseout="hideTip()">
<img src="iicon.gif" border=0 width=16px
height=16px></a><br>
<BR>
Site :
<BR>
<select name="site" class="myform" style="width=235px">
<option value="No Data" style="color:#6666cc"> - Please Select -
</option>
<option value="Andover - Anton Mill Road">Andover - Anton Mill
Road</option>
<option value="Birmingham - Colemore Row">Birmingham - Colemore
Row</option>
<option value="Bristol - Cannon House">Bristol - Cannon
House</option>
<option value="Edinburgh - Edinburgh House">Edinburgh - Edinburgh
House</option>
<option value="Gloucester - Barnwood">Gloucester - Barnwood</option>
<option value="London - Red Lion Court">London - Red Lion
Court</option>
<option value="London - St Georges House">London - St Georges
House</option>
<option value="London - Emerald House">London - Emerald
House</option>
<option value="London - Hayes Lane">London - Hayes Lane</option>
<option value="London - Chiswell Street">London - Chiswell
Street</option>
<option value="London - Princess House">London - Princess
House</option>
<option value="London - Monument">London - Monument</option>
<option value="London - Faryners">London - Faryners</option>
<option value="Manchester - Brotherton House">Manchester -
Brotherton House</option>
<option value="Manchester - Centron House">Manchester - Centron
House</option>
<option value="Manchester - South Gate">Manchester - South
Gate</option>
<option value="Other">Other</option>
</select>
<a href="#"
onmouseover="doTooltip(event,4)" onmouseout="hideTip()">
<img src="iicon.gif" border=0 width=16px
height=16px></a><br>
<BR>
Employee Type :
<BR>
<select name="emp_type" class="myform"
style="width=235px" >
<option value="No Data" style="color:#6666cc"> -
Please Select - </option>
<option value="Permenant Employee">Permenant
Employee</option>
<option value="Contingent
Employee">Contractor</option>
<option value="Management Tainee">Management
Trainee</option>
<option value="Industrial Placement">Industrial
Placement</option>
<option value="Accenture">Accenture</option>
<option value="ART">ART</option>
<option value="Other">Other</option>
</select>
<a href="#"
onmouseover="doTooltip(event,5)" onmouseout="hideTip()">
<img src="iicon.gif" border=0 width=16px
height=16px></a><br>
<BR>
Directorate :
<BR>
<select name="directorate" class="myform"
style="width=235px">
<option value="No Data" style="color:#6666cc"> -
Please Select - </option>
<option value="Application Development">Application
Development</option>
<option value="Application Management">Application
Management</option>
<option value="Business Partnership ( BP )">Business
Partnership ( BP )</option>
<option value="Retail"> - Retail</option>
<option value="Wholesale and International"> -
Wholesale and International</option>
<option value="Change"> - Change</option>
<option value="Cheif Operations Office">Cheif
Operations Office</option>
<option value="Cheif Technology Office ( BP )">Cheif
Technology Office ( BP )</option>
<option value="Finance & Business Support">Finance &
Business Support</option>
<option value="Human Performance">Human
Performance</option>
<option value="Service Delivery">Service
Delivery</option>
<option value="Other">Other</option>
</select>
<a href="#"
onmouseover="doTooltip(event,6)" onmouseout="hideTip()">
<img src="iicon.gif" border=0 width=16px
height=16px></a><br>
<BR>
</TD>
</TR>
<TD COLSPAN=2>
<font face=Verdana size=2>
* Suggestion Title :
<BR>
<input name="title_suggestion"
style="width=525px" maxlenght=50 class="myform" >
<a href="#"
onmouseover="doTooltip(event,7)" onmouseout="hideTip()">
<img src="iicon.gif" border=0 width=16px
height=16px></a><br>
<BR>
* Suggestion :
<BR>
<TEXTAREA name="suggestion" rows=15
style="width=525px" size=250 maxlenght=250
class="myform" ></textarea>
<a href="#"
onmouseover="doTooltip(event,8)" onmouseout="hideTip()">
<img src="iicon.gif" border=0 width=16px
height=16px></a><br>
<BR>
Estimated cost saving ( If Applicable ) :
<BR>
<select name="ecs" class="myform" style="width=285px">
<option value="no_select"> - Please Select -
</option>
<option value="? - ?00">? - ?00</option>
<option value="?01 - ?000">?01 - ?000</option>
<option value="?001 - ?000">?001 - ?000</option>
<option value="?001 - ?000">?001 - ?000</option>
<option value="?001 - ?000">?001 - ?000</option>
<option value="?001 - ?000">?001 - ?000</option>
<option value="?000+">?000+</option>
<option value="Not Sure">Not Sure</option>
</select>
<a href="#"
onmouseover="doTooltip(event,9)" onmouseout="hideTip()">
<img src="iicon.gif" border=0 width=16px
height=16px></a><br>
<BR>
</font>
<input type="hidden" name="ntlogon"
value="">
<input type="hidden" name="remotehost"
value="127.0.0.1">
<input type="submit" value="Submit"
onclick="this.form.submit();this.disabled='true';t his.value='Please
Wait..';">
</td>
</TABLE>
</form>
<div id="tipDiv" style="position:absolute; visibility:hidden;
z-index:100"></div>
<iframe id="tipFrame" style="position:absolute; visibility:hidden;
z-index:90"></iframe>
</body>//////}
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!