0 Replies Latest reply on Nov 3, 2014 7:20 AM by MINDPRESS

    Empty fields set to display non-breaking space if undefined...

    MINDPRESS

      All my empty fields are set to display non-breaking space if undefined (to prevent word "Empty" from appearing in empty fields when the form is printed out). I've used a custom validation script for phone number field, but I can't figure out how remove the non-breaking space (String.fromCharCode(160) that appears before the phone number if the field have been clicked on directly rather than through tab. Any suggestions?


       

      Here is the validation script I have on an Exit event:


       

      if (!(this.isNull)) {

         var str = this.rawValue;

         var regExp = /^\d{10}$/;

         if (regExp.test(str)) {

           this.rawValue = "(" + str.substr(0,3) + ") " + str.substr(3,3) + "-" + str.substr(6,4);

         }

         else {

           regExp  = /^[1-9]\d{2}\s\d{3}\s\d{4}$/;

           if (regExp.test(str)) {

             this.rawValue = "(" + str.substr(0,3) + ") " + str.substr(4,3) + "-" + str.substr(8,4);

           }

           else {

             regExp  = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;

             if (!(regExp.test(str))) {

               xfa.host.messageBox("Please enter the telephone number in the format '(999) 999-9999'.");

               this.rawValue = null;

             }

           }

         }

      }