AnsweredAssumed Answered

Form validation - number

Question asked by chrisokelly on May 30, 2012
Hi Alfrescoer's,

I have a dashlet/webscript I use to display blog posts from all sites matching a particular tag. It's working fine, however today I added an extra validation handler to it's config to user-proof it, since then I am getting a number of errors in client side javascript. The dashlet itself still works fine, however the validation handler does not disable the submit button as expected.

The validation handler is the built in number type (Alfresco.forms.validation.number), which I have not modified. The section of publicNewsFeed.js related to the form validation is -

          doSetupFormsValidation:
          {
            fn: function publicNewsFeed_doSetupForm_callback(form)
            {
              form.addValidation(this.configDialog.id + "-title",
               Alfresco.forms.validation.mandatory, null, "keyup");
              form.addValidation(this.configDialog.id + "-maxPosts",
               Alfresco.forms.validation.mandatory, null, "keyup");
           form.addValidation(this.configDialog.id + "-tagName",
               Alfresco.forms.validation.mandatory, null, "keyup");
           form.addValidation(this.configDialog.id + "-maxPosts",
               Alfresco.forms.validation.number, null, "keyup");
              form.setShowSubmitStateDynamically(true, false);

              Dom.get(this.configDialog.id + "-title").value = this.options.title;
              Dom.get(this.configDialog.id + "-maxPosts").value = this.options.maxPosts;
           Dom.get(this.configDialog.id + "-tagName").value = this.options.tagName;
            },
            scope: this
          }
and config-publicNewsFeed.get.html.ftl is
<div id="${args.htmlid}-configDialog" class="config-publicNewsFeed">
   <div class="hd">${msg("label.dialogTitle")}</div>

   <div class="bd">
      <form id="${args.htmlid}-form" action="" method="POST">
         <div class="yui-gd">
            <div class="yui-u first"><label for="${args.htmlid}-title">${msg("label.title")}:</label></div>
            <div class="yui-u"><input  id="${args.htmlid}-title" type="text" name="title" value="" maxlength="30" /> *</div>
         </div>
         <div class="yui-gd">
            <div class="yui-u first"><label for="${args.htmlid}-maxPosts">${msg("label.maxPosts")}:</label></div>
            <div class="yui-u"><input  id="${args.htmlid}-maxPosts" type="text" name="maxPosts" value="" maxlength="3" /> *</div>
         </div>
         <div class="yui-gd">
            <div class="yui-u first"><label for="${args.htmlid}-tagName">${msg("label.tagName")}:</label></div>
            <div class="yui-u"><input  id="${args.htmlid}-tagName" type="text" name="tagName" value="" maxlength="20" /> *</div>
         </div>
         <div class="bdft">
            <input type="submit" id="${args.htmlid}-ok" value="${msg("button.ok")}" />
            <input type="button" id="${args.htmlid}-cancel" value="${msg("button.cancel")}" />
         </div>
      </form>
   </div>

</div>

When I open the config form in share, I get the following -
[img]http://img823.imageshack.us/img823/2317/validationissue.png[/img]
The rest of the dashlet is still working fine and this does not prevent it from displaying posts or show any error message that normal users (without firebug) can see. It also does not show up any errors in catalina.out or alfresco.log (expected as it's client side). I feel like I am perhaps missing a script import in my publicNewsFeed.js, but seeing as the mandatory validation handlers are working fine I am not sure what I would need to add. Have I done something incorrect in my method of adding the validation?

environment is ubuntu 10.04, tomcat, postgres, alfresco 4.0d community.

Outcomes