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



Dec 19, 2011, 2:23 PM
11 Posts

XPages Validation on multiple fields

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.1
  • Role: Developer
  • Tags:
  • Replies: 2
 Hi,

I need to apply validation on an xpage. Following is the scenario:

1. There is an Xpage having 3 fields.
2. When the user enters the values in these fields, a validation is required to check if the combination of the values in these 3 field is already there in the application,
3. If the combination is there, The data should be saved else data should not be saved and an error should be displayed.

Please let me know the steps to apply the validation listed above. 

In my opinion there should be some provision to write the validation logic for the XPages as a whole and not only for individual field. Please guide.

Thanks,
Atin
Dec 19, 2011, 3:14 PM
23 Posts
Re: XPages Validation on multiple fields
 I'll be fascinated to hear others' ideas on this...
 
You make a view which sorts the documents based on the key values.  Once the fields are completed you have the user click a button to verify the values (or do this on submission) and compare your new key to all of the existing keys via getAllEntriesByKey to see if there is already a match.  Respond appropriately based on what you find.
Dec 20, 2011, 8:33 AM
261 Posts
Re: XPages Validation on multiple fields
Atin,
 
I did a password field validation to check if the 2 passwords that were entered are equal. Using the same method you could validate the value of 3 fields.
 
Mark
 
<xp:this.validators>
<xp:validateExpression message="Passwords are not equal">
<xp:this.expression><![CDATA[#{javascript:if ( !getComponent("password1").getSubmittedValue().equals( getComponent("password2").getSubmittedValue() ) )
{
    return false;
}
else
{
    return true;
}
}]]>
</xp:this.expression>
</xp:validateExpression>
</xp:this.validators>

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