473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

javascript form validation which just doesnt work with my ASP code. Can any one help me out please.



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">&nbsp; - Retail</option>
<option value="Wholesale and International">&nbsp; -

Wholesale and International</option>
<option value="Change">&nbsp; - 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!
Jul 23 '05 #1
7 3556
Here are some hints:
1) You no longer need <!-- -->
2) Use this header line for javascript:
<script type="text/javascript">

3) Use feature detection not browser detection. See:
http://www.jibbering.com/faq/#FAQ4_26

4) Lots of your lines wrapped. For posting to this forum, you need to
either make the lines 72 characters or less or provide a link to a web
site. See:
http://www.jibbering.com/faq/faq_notes/pots1.html

5) You need to trim this down to 50 to 100 lines of the problem code.

6) Use the alert instruction to follow the code.

7) Use Firfox's javascript console to get error message.
getfirefox.com

8) Implement you own debug console so you can print out progress data.
see:
http://groups-beta.google.com/group/...0ddb0d4a45e73b
I tired to edit out the errors but I didn't have any luck.
Robert

Jul 23 '05 #2


Hi Rob,

Thanks for your reply. And here are some problem code, can you please
have a look.

Thanks
///////////////////////////////////////////////
<%

ntlogon = (Request.ServerVariables("LOGON_USER"))
remotehost = (Request.ServerVariables("REMOTE_HOST"))
%>
<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>

</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>

<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="<%=ntlogon%>">
<input type="hidden" name="remotehost"
value="<%=remotehost%>">
<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>
</html>
////////////////////////////////////////////

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3
Here are some more hints for debugging.

1) Validate your html. See:
http://validator.w3.org/

2) You are generating some html code. You can see what this does by
copying and running the following line into the command line:

javascript:'<html><head><title>SourceFileListing<\/title><\/head><body><code><ol><li>'+(document.documentEleme nt||document.body).innerHTML.replace(/&/g,%22&amp;%22).replace(/</g,%22&lt;%22).replace(/%20%20/g,%22&nbsp;%20%22).replace(/\r\n/g,%22<li>%22).replace(/\n/g,%22<li>%22).replace(/\r/g,%22<li>%22)+'<\/ol><\/code><\/body><\/html>';

In google, you can use the term one liner in this group to find more.

3) Use you browser's display source command to see what the server
generated.

4) I conbined parts of the first and second examples. The validation
now happens.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Simple validate</title>

<script type="text/javascript">

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) {
/* Wrong error message. */
alert("Please enter your first name.");
return false;
}
/* Wrong test */
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;

}
</script>
</head>
<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>

</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>

<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="hi">
<input type="hidden" name="remotehost"
value="hi">
<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>
</html>
Robert

Jul 23 '05 #4
JRS: In article <11*********************@f14g2000cwb.googlegroups. com>,
dated Fri, 14 Jan 2005 20:24:20, seen in news:comp.lang.javascript,
Robert <rc*******@my-deja.com> posted :

4) Lots of your lines wrapped. For posting to this forum, you need to
either make the lines 72 characters or less or provide a link to a web
site.


That's not really right.

It is the author's responsibility to ensure that lines are not wrapped
before transmission over the Internet.

It is the reader's responsibility to ensure that the news system he has
chosen to use displays and stores incoming material as he wishes.

Material on a Web site is less likely to be read by those with efficient
off-line newsreaders.

The author may choose to relive ignorant readers, or readers who have
chosen poor software, of their responsibility to themselves; but he
should not do that in a manner that penalises competent users who have
chosen to use good software. In particular, he should not do that if
his material really needs to be displayed wider, as in the case of some
Tables.

The following is a 100-character line which will be transmitted as such.
01234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789

There may be a limit in my system; but there the margin is set at a
nominal yard.

Note : you are using a Web-based service rather than a proper newsreader;
you should not use its behaviour as a guide to what standards-compliant
software will do.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 23 '05 #5
On 14 Jan 2005 11:35:20 -0600, x muzuo <xt****@yahoo.co.uk> wrote:
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:
<< snipped >> <script language="javascript" type="text/javascript">

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;
} << snipped >> return ture;
}

<< much snipped >>

let me offer a piece of code that I use (this is copied directly from one
of my sites) with some validation skipped .... but it should give you the
idea. Your code will cause an alert for each item ... if the user has to
correct each then he might get a bit irritated.

I'm also open to corrections or suggestion on *my* code...

function validForm(frmThis){
intHasError = false;
errList = "You must correct the following errors\nbefore submitting this
form:\n"
if (frmThis.hurdles400.value == "none") {
errList += "\t400 Hurdles\n"
intHasError = true
}
if (frmThis.hurdles300.value == "none") {
errList += "\t300 Hurdles\n"
intHasError = true
}
<< Snipped for readibility >>

if (intHasError) {
alert(errList)
return false
}
return true
}
</script>
<
Jul 23 '05 #6
JRS: In article <opskoebpfhxhg4go@aljones>, dated Sun, 16 Jan 2005
03:20:15, seen in news:comp.lang.javascript, Al Jones
<al**********@shotmail.com> posted :
I'm also open to corrections or suggestion on *my* code...

function validForm(frmThis){
intHasError = false;
errList = "You must correct the following errors\nbefore
submitting this
form:\n"
if (frmThis.hurdles400.value == "none") {
errList += "\t400 Hurdles\n"
intHasError = true
}
if (frmThis.hurdles300.value == "none") {
errList += "\t300 Hurdles\n"
intHasError = true
}
<< Snipped for readibility >>

if (intHasError) {
alert(errList)
return false
}
return true
}

Assuming you snipped a lot, something like this should be better,
unless you are paid by the yard :-

function validForm(frmThis){ var J, errList = "",
A = ['Hurdles400', 'Hurdles300'],
Ho = "You must correct the following errors\n" +
"before submitting this form:\n"
for (J=0 ; J<A.length ; J++)
if (frmThis.elements[A[J]].value == "none")
errList += "\t" + A[J] + "\n"
if (errList) alert(Ho+errList)
return !errList }

The chief point is to use a loop rather than repeating similar code.
Note case of H.

Please do not indent by tabs in news and then allow line-wrap - see FAQ.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #7
On Sun, 16 Jan 2005 19:45:56 +0000, Dr John Stockton
<sp**@merlyn.demon.co.uk> wrote:

Assuming you snipped a lot, something like this should be better,
unless you are paid by the yard :-

function validForm(frmThis){ var J, errList = "",
A = ['Hurdles400', 'Hurdles300'],
Ho = "You must correct the following errors\n" +
"before submitting this form:\n"
for (J=0 ; J<A.length ; J++)
if (frmThis.elements[A[J]].value == "none")
errList += "\t" + A[J] + "\n"
if (errList) alert(Ho+errList)
return !errList }

The chief point is to use a loop rather than repeating similar code.
Note case of H.

Please do not indent by tabs in news and then allow line-wrap - see FAQ.


Hi Doc, I like that and will keep it in mind. I did snip a lot of code,
and actually those two are now logicals (thanks to another comment). Some
are logicals, some text and some numeric - in disgustingly no particular
order. So, on that I thank you.

On the other part of the note, your comment, by itself, would have been
enough to bring the tabs to my attention and correct it in any other posts
- smiling - I've read the FAQ's and obviously missed some <??> you don't
need to slap my wrist with the faq's to get my attention, a comment was
more than sufficient.
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: john | last post by:
I have 2 major issues currently with javascript. 1. Doesnt anybody do any server side javascript anymore. I cant find anything on the net about it. My major issue is with database connections...
7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
5
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one...
6
by: x muzuo | last post by:
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: ...
5
by: Allan M. | last post by:
I have a series of select boxes that must be populated client side, because they interact with each other. The design specification calls for these boxes to be updated without having to make a...
1
by: Muhammad Abdullah | last post by:
Hi am having some problems with the javascript confirm. i have it working fine on one page and it doesnt even pop up at the other. The code on the working page is, private void...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
1
by: fran7 | last post by:
hi, I have two javascript form validation scripts. Although the forms have different names, one of the scripts overrides the other and validates both. They have the same onsubmit, and one has a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.