This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 25, 2011, 1:53 PM
66 Posts

<xp:customValidator> Validation

  • Category: Other
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: SSJS,validation
  • Replies: 1
I came across this article by Andre Guirard: http://www-10.lotus.com/ldd/bpmpblog.nsf/dx/better-ssjs-validation-for-xpages?opendocument&comments#anc1
 
What would be the best way to check for an empty field with this method? It seems as if nothing is entered into the field, nothing gets called. I'm a beginner to JavaScript...sorry if the answer is obvious. I've tried the if statement below, but nothing gets flagged.
 
              <xp:this.validate>
                      <![CDATA[#{javascript:
                        var val = value;
                        if (val == null)
                            postValidationError(this, "Field is required");
                        }]]>
              </xp:this.validate>
Mar 28, 2011, 2:52 PM
23 Posts
Re: <xp:customValidator> Validation
Not sure if this will help but I suspect it will.
 
CustomValidators are not invoked if there is no value entered into a field.  There is a switch that can be flipped in JSF 2.0 to change that default behavior but I have not found a way to flip that switch in XPages.
 
Consequently, if all you are doing is requiring a field, just use the required validator and you will be fine.  If you need "dynamic requiring", then compute the "required" property as needed.

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal