<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>Hi, I'm having trouble with the following two functions.
They were generated by dreamweaver. The functions work together to
validate a form. MM_validateForm() is called on submitting the form,
and in turn calls MM_findObj, which takes a form input name passed to
MM_validate form and returns the input object of that name.
MM_validateForm() takes in parameters in triplets. For instance, if I had
only one required parameter called 'Name', I would call
MM_validateForm('Name','','R'), where R is the flag indicating the field is
required. If I had 2 name fields I wanted to validate it would be
</FONT></DIV>
<DIV><FONT size=2>MM_validateForm('Name1','','R','Name2','','R') and etc,
inductively. I'm not sure what the second parameter in each triplet
set is for. Anyway, there are two problems here. </FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>The first problem is that if one of the parameters I'm trying
to require is a checkbox, the script looks at its value as though it was
checked. IE if the value of the checkbox is 'yes' the script returns a
'yes' regardless of whether the box was checked, and therefore the field is not
made required. </FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>The second problem is that when I have a radio input the
script considers the name and value of it to be undefined all the time.
</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>I can write a simpler and more proprietary script for this but
am pretty confused as to why this one is not working.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Does anyone have any ideas concerning this?</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Thanks,</FONT></DIV>
<DIV><FONT size=2>david.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2><!--<BR>function MM_findObj(n, d) { //v4.0<BR> var
p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length)
{<BR> d=parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);}<BR> if(!(x=d[n])&&d.all) x=d.all[n]; for
(i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];<BR>
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);<BR> if(!x &&
document.getElementById) x=document.getElementById(n); return
x;<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>function MM_validateForm() { //v4.0<BR> var
i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;<BR>
for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
val=MM_findObj(args[i]);<BR> if (val) { nm=val.name; if
((val=val.value)!="") {<BR> if
(test.indexOf('isEmail')!=-1) {
p=val.indexOf('@');<BR> if (p<1 ||
p==(val.length-1)) errors+='- '+nm+' must contain an e-mail
address.\n';<BR> } else if (test!='R')
{<BR> if (isNaN(val)) errors+='-
'+nm+' must contain a number.\n';<BR>
if (test.indexOf('inRange') != -1) {
p=test.indexOf(':');<BR>
min=test.substring(8,p);
max=test.substring(p+1);<BR>
if (val<min || max<val) errors+='- '+nm+' must contain a number between
'+min+' and '+max+'.\n';<BR> } } } else if (test.charAt(0) ==
'R') errors += '- '+nm+' is required.\n'; }<BR> } if (errors) alert('The
following error(s) occurred:\n'+errors);<BR> document.MM_returnValue =
(errors == '');<BR>}<BR>//--></FONT></DIV></BODY></HTML>