FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



Jul 11, 2012, 3:18 AM
21 Posts

Validate combination of 2 fields

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 2
Hi,
 
I'm a bit confuse on how validation works as I am very new in XPages...
What I am trying to do is to validate the combination of 2 fields
 
1) Let say the 2 fields is "Make" and "Model" 
2) I already create a view and name as "ViewCar" 
3) I enter a data - Make is "Honda" and Model is "CRV" ( I combine and it become "HondaCRV")
4) I want to enter a new data and I want to make sure I will not enter the same  data.
 
How can I do this? Can I just use validator to check this and prompt me. 
 
TQ. 
 
Jul 11, 2012, 4:17 AM
126 Posts
Re: Validate combination of 2 fields
There is a validator that just lets you type in javascript and return true / false so you can do what ever you like inside it.
 
<xp:inputText value="...."> 
     <xp:this.validators> 
          <xp:validateExpression message="validation failed"> 
               <xp:this.expression><![CDATA[#{javascript:
                    
                   if( < already exists > )
                   {
                        return false; // fails validation
                   } 
                   else 
                   { 
                        return true; // passes validation
                   } 
 
               }]]></xp:this.expression> 
          </xp:validateExpression> 
     </xp:this.validators> 
</xp:inputText> 
Oct 16, 2012, 9:23 PM
21 Posts
Re: Validate combination of 2 fields
 Thanks Simon... appreciate your help.

FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.