sitecore8 - Sitecore WFFM validation not kicking in -


in sitecore 8.0 created new wffm validation test file upload size. did creating new class inherited formcustomvalidator , created matching sitecore validator , added new validator custom file upload field (duplicate of sitecore file upload field). unfortunately, validation not kicking in when place new field on form. did miss?

public class filesizevalidator : formcustomvalidator     {          public int maxfilesize         {                         {                 log.info("maxfilesize get", this);                 int maxsize;                 if (int.tryparse(classattributes["maxfilesize"], out maxsize))                 {                     return maxsize;                 }                 return 0;             }             set             {                 log.info("maxfilesize set", this);                 base.classattributes["maxfilesize"] = value.tostring();             }         }          public filesizevalidator()         {             log.info("filesizevalidator", this);             servervalidate += new servervalidateeventhandler(onvalidate);         }          private void onvalidate(object source, servervalidateeventargs args)         {             log.info("onservervalidate", this);             fileupload fileupload = findcontrol(controltovalidate) fileupload;             if (!fileupload.hasfile)             {                 args.isvalid = true;                 return;             }             args.isvalid = fileupload.postedfile.contentlength <= maxfilesize;         }          protected override bool evaluateisvalid()         {             try             {                 if (!string.isnullorempty(this.controltovalidate))                     return base.evaluateisvalid();                 else                     return true;             }             catch (argumentoutofrangeexception ex)             {                 return false;             }         }          protected override void onload(eventargs e)         {             this.errormessage = "error message";             this.text = "text";             base.onload(e);         }     } 


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -