2 Replies Latest reply on Jul 27, 2010 2:04 PM by garyhatt

    Keeping focus after validation error and alert

    garyhatt Level 1

      I have some code that works about like I want with one small glitch. The alert works when the character count in incorrect, and it keeps focus on the field. The problem is that after the correct number of characters are entered in the field, it still keeps focus on the field until you tab out of it.

       

      I need it to work like it does, with the exception that when the correct number of characters is entered, it needs to go to the next field automatically.

       

      If the alert is removed, it works correctly, except, of course, I do not get the alert. Here is my code.

       


      var r = new RegExp();
        r.compile("^([0-9]{8})$","i");

       

      var result = r.test(this.rawValue);

       

      if (result == true)

       

          true;

       

      else
          app.alert("SAP numbers are 8 digits. Please re-enter the SAP number.", 0);
          xfa.host.setFocus(this);

       

      Thanks