1 Reply Latest reply on Mar 14, 2014 4:33 PM by try67

    Need validation script for charlimit (9) with option to reset field or leave field blank

    lslocum

      Can the below validation script be corrected to do the following:

      1. Require 9 characters- numbers only or be left blank
      2. If less than 9 characters entered, then clear the field and leave cursor in the field to require a user to either enter 9 numbers or leave blank
      3. If user clicks of the Reset Form button at the top of the page, allow it to clear this field as well
      4. Keep auto tab function to move to account field

       

      Here is the validation script I have currently.  Main issues:  (1) When trying to use the Reset Form button or manually clearing out the field I am recieving an error saying "field length must be equal to 9"

       

      Format Script

      function AutoTab(doc, event, cNext)

      {

      // Call the built-in routine to allow numbers only.

      AFNumber_Keystroke(0, 0, 0, 0, "", true);

      // If we've filled in the field completely, jump to the next one.

      if (event.rc && AFMergeChange(event).length == event.target.charLimit)

        doc.getField(cNext).setFocus();

      }

       

      Keystroke script

      AutoTab(this, event, "Account");

       

      Validate script

      event.rc = true;

      if (event.value.length != event.target.charLimit)

        {

        app.alert("Field length must be equal to " + event.target.charLimit );

        event.rc = false;

        }