3 Replies Latest reply on Sep 14, 2018 12:57 PM by Joe Upshaw

    Validation for a semicolon in a PopUp LOV

    Tod Goulds-Oracle

      HI there,

       

      I have created a validation on a PopUP LOV, that also allows free text entry to check that there are no semicolon values in the item...

       

      Validation used:

      "Item does NOT contain any of the characters in Value"

       

      Value used:

      ;

       

      however this doesn't work, (actually causes a page issue)... is there any way to check this is there some kind of special string to check for a ;

       

      thanks

       

      tod

        • 1. Re: Validation for a semicolon in a PopUp LOV
          Pavel_p

          Hi Tod,

          I can't reproduce it in 5.1.4 and 18.1. either - validation on Popup LOV works exactly as expected (no matter if it's defined in shared components or as Static values: STATIC:with semicolon;a;b,semicolon only;;,without semicolon;ab). Please, could you describe in more detail what you did and what APEX version you're using?

          Thanks

          Pavel

          • 2. Re: Validation for a semicolon in a PopUp LOV
            fac586

            Tod Goulds-Oracle wrote:

             

            I have created a validation on a PopUP LOV, that also allows free text entry to check that there are no semicolon values in the item...

             

            Validation used:

            "Item does NOT contain any of the characters in Value"

             

            Value used:

            ;

             

            however this doesn't work, (actually causes a page issue)... is there any way to check this is there some kind of special string to check for a ;

            I cannot reproduce any problem either. What is the "page issue" referred to?

            • 3. Re: Validation for a semicolon in a PopUp LOV
              Joe Upshaw

              Warning...javascripty answer.

               

              To enforce a "White List" of allowable characters, I do the following:

               

              1. Add a class to the input on which I'd like the validation to be active, regularExpressionCheck
              2. Add an additional property to the input, regularExpressionMatch
                1. The value of the property in my case it set to an application item, regularExpressionMatch="&ALLOWABLE_DATASET_REG_EXP." but, you couold hard code one here. For me, this item, ALLOWABLE_DATASET_REG_EXP, is set to [^A-Za-z0-9_], i.e. just letters, numbers and _.
              3. Then I have a bit a JS to check if the value matches the RegExp whitelist.
              function regularExpressionCheck( validationValue, validationDisplay, regularExpressionMatch )
              {
                  var testRegExpObj = new RegExp( regularExpressionMatch );
              
              
                  var hasUndesiredContent = testRegExpObj.test( validationValue );
              
              
                  if( hasUndesiredContent === true )
                  {
                      var invalidCharacters = '';
                      var currentForbiddenCharacter;
              
              
                      while ( (invalidCharacterArray = testRegExpObj.exec( validationValue ) ) !== null )
                      {
                          currentForbiddenCharacter = invalidCharacterArray[0];
              
              
                          if( invalidCharacters.indexOf(currentForbiddenCharacter) === -1 )
                          {
                              invalidCharacters = invalidCharacters + currentForbiddenCharacter;
                          }
              
              
                          validationValue = validationValue.substr( testRegExpObj.lastIndex + 1 );
                      }
                      
                      this.errorMsg = validationDisplay + ' contains disallowed characters: "' + invalidCharacters + '"';
                      this.cellHasError = true;      
                  }
                  else
                  {
                      this.cellHasError = false;
                  } 
              }
              
              
              
              
              
              
              
              
              
              
              
              

               

              So, to call this, I just find any elements with this class, whenever one if found, I call:

               

              regularExpressionMatch = $(childNode).attr("regularexpressionmatch");
              validationCheckObj = new regularExpressionCheck( childValue, displayHeader, regularExpressionMatch );  
              

               

              If the validation object has an error, raise it.

               

              if ( validationCheckObj.cellHasError === true )
              {                                          
                  conditionallyAddError( validationCheckObj.cellHasError,
                                         $(childNode),
                                         $(childNode).attr('id'),
                                         validationCheckObj.errorMsg,
                                         errorList, 
                                         internalErrorCnt,
                                         errorClass );    
                                         
                  errorCnt = errorCnt + 1;                                                                                                                                                                   
              }
              
              
              
              1 person found this helpful