Hello,
It should be working but for some reasons it's not.
[code="JavaScrip t"]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.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 uploaderError()
{
var frm = document.forms["upload"];
var uplSplit = frm.filePath.va lue.match("^(.+ ).(.+)$");
if (uplSplit == null) { ErrorPath(); return false; }
if (uplSplit[2] != null )
{
if ((uplSplit[2].match("gif") == null) || (uplSplit[2].match("jpg") == null) || (uplSplit[2].match("jpg") == null))
{ ErrorPath(); return false; }
else { return true; }
}
if (frm.filePath.v alue == '')
{
ErrorPath();
return false;
}
else if ((frm.Title.val ue == '') || (strlen(frm.Tit le.value) > 15))
{
ErrorTitle();
return false;
}
else if ((frm.height.va lue != '') && (frm.width.valu e == ''))
{
Errorresize();
return false;
}
else if ((frm.hieght.va lue != '') && (frm.width.valu e == ''))
{
Errorresize();
return false;
}
else if ((frm.pincode.v alue != '') && (frm.memid.valu e == ''))
{
ErrorMem();
return false;
}
else if ((frm.memid.val ue != '') && (frm.pincode.va lue == ''))
{
ErrorMem();
return false;
}
else
{
return true;
}
}[/code]
[code="JavaScrip t"]<form action="process .php" method="post" name="upload">[/code]
outside form
[code="HTML4Stri ct"]</form>
<script language="JavaS cript" type="text/javascript">
var frmCheck = new Validator("uplo ad");
frmCheck.setAdd nlValidationFun ction("uploader Error");
</script>[/code]
form name is "upload". The problem is, it's not going through the checks.
Thanks in Advace.
It should be working but for some reasons it's not.
[code="JavaScrip t"]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.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 uploaderError()
{
var frm = document.forms["upload"];
var uplSplit = frm.filePath.va lue.match("^(.+ ).(.+)$");
if (uplSplit == null) { ErrorPath(); return false; }
if (uplSplit[2] != null )
{
if ((uplSplit[2].match("gif") == null) || (uplSplit[2].match("jpg") == null) || (uplSplit[2].match("jpg") == null))
{ ErrorPath(); return false; }
else { return true; }
}
if (frm.filePath.v alue == '')
{
ErrorPath();
return false;
}
else if ((frm.Title.val ue == '') || (strlen(frm.Tit le.value) > 15))
{
ErrorTitle();
return false;
}
else if ((frm.height.va lue != '') && (frm.width.valu e == ''))
{
Errorresize();
return false;
}
else if ((frm.hieght.va lue != '') && (frm.width.valu e == ''))
{
Errorresize();
return false;
}
else if ((frm.pincode.v alue != '') && (frm.memid.valu e == ''))
{
ErrorMem();
return false;
}
else if ((frm.memid.val ue != '') && (frm.pincode.va lue == ''))
{
ErrorMem();
return false;
}
else
{
return true;
}
}[/code]
[code="JavaScrip t"]<form action="process .php" method="post" name="upload">[/code]
outside form
[code="HTML4Stri ct"]</form>
<script language="JavaS cript" type="text/javascript">
var frmCheck = new Validator("uplo ad");
frmCheck.setAdd nlValidationFun ction("uploader Error");
</script>[/code]
form name is "upload". The problem is, it's not going through the checks.
Thanks in Advace.
Comment