Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Your form has a text control requiring a Social Security number. The JavaScript below will automatically add the hyphens while the user is entering the SSN.  Add SSN to the CSS Class property of the control to enable this JavaScript.  

Code Block
   var CustomEventHandlers = {
       setup: function (el) {
           if (CustomView.hasClass(el, 'SSN')) {
               FEvent.observe(el, 'keydown', this.formatSSN.bindAsObserver(this, el));
               FEvent.observe(el, 'keyup', this.formatSSN.bindAsObserver(this, el));
           }
       },
       formatSSN: function (event, element) {
           if (event.keyCode != 46 && event.keyCode != 8) {
               fldVal = $(element).value;
               var nom = fldVal.charAt(fldVal.length - 1);
               if (isNaN(nom) && nom != "-") {
                   $(element).value = fldVal.substring(0, fldVal.length - 1);
               } else {
                   if ((fldVal.length == 3) || (fldVal.length == 6)) {
                       $(element).value = fldVal + "-";
                   }
                   if (fldVal.length >= 11) {
                       $(element).value = fldVal.substring(0, fldVal.length - 1);
                   }
               }
           }
       }
   }   

...

Code Block
var CustomEventHandlers = {
   setup: function (el) {
       if (CustomView.hasClass(el, 'extra-submit')) {
           FEvent.observe(el, 'click', this.autoSubmit.bindAsObserver(this, el));
       }
   },
   autoSubmit: function (evt, el) {
       FlowView.getFlowButton().onclick();
   }
}

 

Prevent Session Timeout

Sometimes you may need the session timeout for a particular form to be a lot longer than the default session timeout that makes sense for your entire tenant. Imagine your /wiki/spaces/frevvo52/pages/683376648 timeout in  is set to 30 minutes. One of your forms takes a long time to fill out. You want to allow idle periods greater than 30 minutes for that form only.

...

Code Block
languagejavascript
if (form.load) { 
  username.value = _data.getParameter('subject.id');
}

Phone Dash

This custom javascript automatically inserts dashes as the user enters a phone number into a Phone control. Characters other than the dash entered into the control are deleted. Add PhoneInsert to the CSS Class property of the Phone control to enable this JavaScript. 

Code Block
languagejavascript
PHONE DASH FILL
<script>
        /* <![CDATA[ */
 
   var CustomEventHandlers = {
       setup: function (el) {
           if (CustomView.hasClass(el, 'PhoneInsert')) {
               FEvent.observe(el, 'keydown', this.formatPHONE.bindAsObserver(this, el));
               FEvent.observe(el, 'keyup', this.formatPHONE.bindAsObserver(this, el));
           }

       },

       formatPHONE: function (event, element) {
           if (event.keyCode != 46 && event.keyCode != 8) {
               fldVal = $(element).value;
               var nom = fldVal.charAt(fldVal.length - 1);
               if (isNaN(nom) && nom != "-") {
                   $(element).value = fldVal.substring(0, fldVal.length - 1);
               } else {
                   if ((fldVal.length == 3) || (fldVal.length == 7)) {
                       $(element).value = fldVal + "-";
                   }
                   if (fldVal.length > 12) {
                       $(element).value = fldVal.substring(0, fldVal.length - 1);
                   }
               }
           }
       }
   }
  
/* ]]> */
    </script>