I have the following code
<html>
<head>
<title>Untitl ed Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaS cript" src="..\include \gen_validatorv 2.js"
type="text/javascript"></script>
</head>
<body bgcolor="#FFFFF F" text="#000000">
<form action="" method="post" name="myform" >
<table width="255" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td width="10" height="10"></td>
<td width="100"></td>
<td width="80"></td>
<td width="5"></td>
<td width="15"></td>
<td width="45"></td>
</tr>
<tr>
<td height="28"></td>
<td valign="top" colspan="4">ema il:
<input type="text" name="email">
</td>
<td></td>
</tr>
<tr>
<td height="17"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="28"></td>
<td valign="top" colspan="2">ema il2:
<input type="text" name="email2">
</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="17"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="20"></td>
<td></td>
<td colspan="2" valign="top">
<input type="submit" name="Submit" value="Submit">
</td>
<td></td>
<td></td>
</tr>
<tr>
<td height="17"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<SCRIPT language="JavaS cript">
var frmvalidator = new Validator("myfo rm");
frmvalidator.se tAddnlValidatio nFunction("DoCu stomValidation" );
frmvalidator.ad dValidation("em ail","req");
frmvalidator.ad dValidation("em ail","email");
frmvalidator.ad dValidation("em ail2","req");
frmvalidator.ad dValidation("em ail2","email");
</script>
</form>
</body>
</html>
and the file gen_validatorv2 .js contains
/*
-------------------------------------------------------------------------
JavaScript Form Validator
Version 2.0.2
Copyright 2003 JavaScript-coder.com. All rights reserved.
You use this script in your Web pages, provided these opening credit
lines are kept intact.
The Form validation script is distributed free from JavaScript-Coder.com
You may please add a link to JavaScript-Coder.com,
making it easy for others to find this script.
Checkout the Give a link and Get a link page:
http://www.javascript-coder.com/links/how-to-link.php
You may not reprint or redistribute this code without permission from
JavaScript-Coder.com.
JavaScript Coder
It precisely codes what you imagine!
Grab your copy here:
http://www.javascript-coder.com/
------------------------------------------------------------------------
-
*/
function DoCustomValidat ion()
{
var frm = document.forms["myform"];
if(frm.email.va lue != frm.email2.valu e)
{
alert('The Email and verified Email does not match!');
return false;
}
else
{
return true;
}
}
function Validator(frmna me)
{
this.formobj=do cument.forms[frmname];
if(!this.formob j)
{
alert("BUG: couldnot get Form object "+frmname);
return;
}
if(this.formobj .onsubmit)
{
this.formobj.ol d_onsubmit = this.formobj.on submit;
this.formobj.on submit=null;
}
else
{
this.formobj.ol d_onsubmit = null;
}
this.formobj.on submit=form_sub mit_handler;
this.addValidat ion = add_validation;
this.setAddnlVa lidationFunctio n=set_addnl_vfu nction;
this.clearAllVa lidations = clear_all_valid ations;
}
function set_addnl_vfunc tion(functionna me)
{
this.formobj.ad dnlvalidation = functionname;
}
function clear_all_valid ations()
{
for(var itr=0;itr < this.formobj.el ements.length;i tr++)
{
this.formobj.el ements[itr].validationset = null;
}
}
function form_submit_han dler()
{
for(var itr=0;itr < this.elements.l ength;itr++)
{
if(this.element s[itr].validationset &&
!this.elements[itr].validationset. validate())
{
return false;
}
}
if(this.addnlva lidation)
{
str =" var ret = "+this.addnlval idation+"()";
eval(str);
if(!ret) return ret;
}
return true;
}
function add_validation( itemname,descri ptor,errstr)
{
if(!this.formob j)
{
alert("BUG: the form object is not set properly");
return;
}//if
var itemobj = this.formobj[itemname];
if(!itemobj)
{
alert("BUG: Couldnot get the input object named: "+itemname) ;
return;
}
if(!itemobj.val idationset)
{
itemobj.validat ionset = new ValidationSet(i temobj);
}
itemobj.validat ionset.add(desc riptor,errstr);
}
function ValidationDesc( inputitem,desc, error)
{
this.desc=desc;
this.error=erro r;
this.itemobj = inputitem;
this.validate=v desc_validate;
}
function vdesc_validate( )
{
if(!V2validateD ata(this.desc,t his.itemobj,thi s.error))
{
this.itemobj.fo cus();
return false;
}
return true;
}
function ValidationSet(i nputitem)
{
this.vSet=new Array();
this.add= add_validationd esc;
this.validate= vset_validate;
this.itemobj = inputitem;
}
function add_validationd esc(desc,error)
{
this.vSet[this.vSet.lengt h]=
new ValidationDesc( this.itemobj,de sc,error);
}
function vset_validate()
{
for(var itr=0;itr<this. vSet.length;itr ++)
{
if(!this.vSet[itr].validate())
{
return false;
}
}
return true;
}
function validateEmailv2 (email)
{
// a very simple email validation checking.
// you can add more complex email checking if it helps
if(email.length <= 0)
{
return true;
}
var splitted = email.match("^( .+)@(.+)$");
if(splitted == null) return false;
if(splitted[1] != null )
{
var regexp_user=/^\"?[\w-_\.]*\"?$/;
if(splitted[1].match(regexp_u ser) == null) return false;
}
if(splitted[2] != null)
{
var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
if(splitted[2].match(regexp_d omain) == null)
{
var regexp_ip =/^\[\d{1,3}\.\d{1,3 }\.\d{1,3}\.\d{ 1,3}\]$/;
if(splitted[2].match(regexp_i p) == null) return false;
}// if
return true;
}
return false;
}
function V2validateData( strValidateStr, objValue,strErr or)
{
var epos = strValidateStr. search("=");
var command = "";
var cmdvalue = "";
if(epos >= 0)
{
command = strValidateStr. substring(0,epo s);
cmdvalue = strValidateStr. substr(epos+1);
}
else
{
command = strValidateStr;
}
switch(command)
{
case "req":
case "required":
{
if(eval(objValu e.value.length) == 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : Required Field";
}//if
alert(strError) ;
return false;
}//if
break;
}//case required
case "maxlength" :
case "maxlen":
{
if(eval(objValu e.value.length) > eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : "+cmdvalue+ " characters
maximum ";
}//if
alert(strError + "\n[Current length = " +
objValue.value. length + " ]");
return false;
}//if
break;
}//case maxlen
case "minlength" :
case "minlen":
{
if(eval(objValu e.value.length) < eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : " + cmdvalue + " characters
minimum ";
}//if
alert(strError + "\n[Current length = " +
objValue.value. length + " ]");
return false;
}//if
break;
}//case minlen
case "alnum":
case "alphanumer ic":
{
var charpos = objValue.value. search("[^A-Za-z0-9]");
if(objValue.val ue.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+" : Only alpha-numeric characters
allowed ";
}//if
alert(strError + "\n [Error character position " +
eval(charpos+1) +"]");
return false;
}//if
break;
}//case alphanumeric
case "num":
case "numeric":
{
var charpos = objValue.value. search("[^0-9]");
if(objValue.val ue.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+" : Only digits allowed ";
}//if
alert(strError + "\n [Error character position " +
eval(charpos+1) +"]");
return false;
}//if
break;
}//numeric
case "alphabetic ":
case "alpha":
{
var charpos = objValue.value. search("[^A-Za-z]");
if(objValue.val ue.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+" : Only alphabetic characters
allowed ";
}//if
alert(strError + "\n [Error character position " +
eval(charpos+1) +"]");
return false;
}//if
break;
}//alpha
case "alnumhyphe n":
{
var charpos = objValue.value. search("[^A-Za-z0-9\-_]");
if(objValue.val ue.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+" : characters allowed are
A-Z,a-z,0-9,- and _";
}//if
alert(strError + "\n [Error character position " +
eval(charpos+1) +"]");
return false;
}//if
break;
}
case "email":
{
if(!validateEma ilv2(objValue.v alue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name+" : Enter a valid Email address
";
}//if
alert(strError) ;
return false;
}//if
break;
}//case email
case "lt":
case "lessthan":
{
if(isNaN(objVal ue.value))
{
alert(objValue. name+": Should be a number ");
return false;
}//if
if(eval(objValu e.value) >= eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : value should be less than "+
cmdvalue;
}//if
alert(strError) ;
return false;
}//if
break;
}//case lessthan
case "gt":
case "greatertha n":
{
if(isNaN(objVal ue.value))
{
alert(objValue. name+": Should be a number ");
return false;
}//if
if(eval(objValu e.value) <= eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : value should be greater than
"+ cmdvalue;
}//if
alert(strError) ;
return false;
}//if
break;
}//case greaterthan
case "regexp":
{
if(objValue.val ue.length > 0)
{
if(!objValue.va lue.match(cmdva lue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name+" : Invalid characters found ";
}//if
alert(strError) ;
return false;
}//if
}
break;
}//case regexp
case "dontselect ":
{
if(objValue.sel ectedIndex == null)
{
alert("BUG: dontselect command for non-select Item");
return false;
}
if(objValue.sel ectedIndex == eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name+" : Please Select one option ";
}//if
alert(strError) ;
return false;
}
break;
}//case dontselect
}//switch
return true;
}
/*
Copyright 2003 JavaScript-coder.com. All rights reserved.
*/
The problem is that I get the following error Line:70 Error: Object
expected.
I have tryed always for this to work and looked through google but to no
vail Please can someone help.