It should be working but for some reasons it's not.
Expand|Select|Wrap|Line Numbers
- function Validator(frmname)
- {
- this.formobj=document.forms[frmname];
- if(!this.formobj)
- {
- alert("BUG: couldnot get Form object "+frmname);
- return;
- }
- if(this.formobj.onsubmit)
- {
- this.formobj.old_onsubmit = this.formobj.onsubmit;
- this.formobj.onsubmit=null;
- }
- else
- {
- this.formobj.old_onsubmit = null;
- }
- this.formobj.onsubmit=form_submit_handler;
- this.setAddnlValidationFunction=set_addnl_vfunction;
- this.clearAllValidations = clear_all_validations;
- }
- function set_addnl_vfunction(functionname)
- {
- this.formobj.addnlvalidation = functionname;
- }
- function clear_all_validations()
- {
- for(var itr=0;itr < this.formobj.elements.length;itr++)
- {
- this.formobj.elements[itr].validationset = null;
- }
- }
- function form_submit_handler()
- {
- for(var itr=0;itr < this.elements.length;itr++)
- {
- if(this.elements[itr].validationset &&
- !this.elements[itr].validationset.validate())
- {
- return false;
- }
- }
- if(this.addnlvalidation)
- {
- str =" var ret = "+this.addnlvalidation+"()";
- eval(str);
- if(!ret) return ret;
- }
- return true;
- }
- function uploaderError()
- {
- var frm = document.forms["upload"];
- var uplSplit = frm.filePath.value.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.value == '')
- {
- ErrorPath();
- return false;
- }
- else if ((frm.Title.value == '') || (strlen(frm.Title.value) > 15))
- {
- ErrorTitle();
- return false;
- }
- else if ((frm.height.value != '') && (frm.width.value == ''))
- {
- Errorresize();
- return false;
- }
- else if ((frm.hieght.value != '') && (frm.width.value == ''))
- {
- Errorresize();
- return false;
- }
- else if ((frm.pincode.value != '') && (frm.memid.value == ''))
- {
- ErrorMem();
- return false;
- }
- else if ((frm.memid.value != '') && (frm.pincode.value == ''))
- {
- ErrorMem();
- return false;
- }
- else
- {
- return true;
- }
- }
Expand|Select|Wrap|Line Numbers
- <form action="process.php" method="post" name="upload">
Expand|Select|Wrap|Line Numbers
- </form>
- <script language="JavaScript" type="text/javascript">
- var frmCheck = new Validator("upload");
- frmCheck.setAddnlValidationFunction("uploaderError");
- </script>
Thanks in Advace.