Expand my Community achievements bar.

SOLVED

Button should VISIBLE only if user entered all mandatory fields?

Avatar

Level 8

Hello

I have 10 fields on the form, 3 are required/mandatory fields to enter the data. And i also kept a button with caption CHECK FIELDS.

I also kept a 2nd button, say the caption is GOOD TO GO (its not a SUBMIT button, both buttons are normalbuttons)

At ths point, GOOD TO GO button is "hidden'

Now, say, user forgot to enter in 2 required fields, and pressed CHECK FIELDS button, user prompted 2 times with popup the respect field captions.

Now, user entered in 1 field and forgot again to enter the data in another field and pressed CHECK FIELDS button, user prompted 1 time with a popup with the respect field caption.

Now, user entered that field also, fine, and pressed CHECK FIELDS button, user DID NOT prompted with any popup.

BUT AT THIS POINT, i need to SHOW/PRESENCE the GOOD TO GO button

Pls. let me know how can get it done in JavaScript?

Thank you

1 Accepted Solution

Avatar

Correct answer by
Level 7

You were missing a ; after each statement--none needed after "else". Not sure what you're doing with b? Does b get used somewhere? Also, I think I fixed your resolveNode syntax. Give it a try.

for (var i = 0; i < myArray.length; i++) { 
      if (xfa.resolveNode("VISITORINFO[" + i +"]").rawValue == null){
           b = xfa.resolveNode("VISITORINFO[" +
i +"]").caption.value.text.value;
           x = "BAD";

          app.alert (x);
           }
      else
      {
      if (x != "BAD"){
           x = "GOOD" ;
          app.alert (x);
     }
      }

}

Good luck!

Stephen

View solution in original post

6 Replies

Avatar

Level 7

Hi,

Place on the calculate event of the button:

       if(Field1.rawValue > "" &               //you could use 0 instead of ""

          Field2.rawValue > "" &

          Field3.rawValue > "" &

          Field4.rawValue > "" &

          Field5.rawValue > "" &

          Field6.rawValue > "" &

          Field7.rawValue > "" &

          Field8.rawValue > "" &

          Field9.rawValue > "" &

          Field10.rawValue > "" ){

               this.presence = "visible";

                    }else{

               this.presence = "hidden";

               }

Good luck!

Stephen

Avatar

Level 8

Oh, Sorry ... i did not mentioned in my original question that, these mandatory fields are dynamic in #, meaning, for user_1 they are 5 in #, where as for the user_2 they 3 in #, and for user_3..... and for user_4 so on...but at the form launching time, we knew the NUMBER (3 or 5 or ....)but the form is the same.

Need to do LOOP, where i stuck. I have 2 buttons on the screen, 1st CHECK FIELDS and 2nd GOOD TO GO

Thank you

Avatar

Level 7

Sorry, I completely missed that--I thought all were required. Yes, you would use a loop.

Stephen

Avatar

Level 8

Thank you.

If u get a chance, pls. let me know code snippet in JS, bcz the below is not working for me!

for (var i = 0; i < myArray.length; i++)   

if (xfa.resolveNode("VISITORINFO." + myArray[i]).rawValue == null){
b = xfa.resolveNode("VISITORINFO.." + myArray[i]).caption.value.text.value 
x = "BAD"
  app.alert (x)
}
else;
{
if (x != "BAD"){
x = "GOOD"
app.alert (x)
}
}
}

Here BAD = HIDDEN and GOOD = VISIBLE of button

Thank you

Avatar

Correct answer by
Level 7

You were missing a ; after each statement--none needed after "else". Not sure what you're doing with b? Does b get used somewhere? Also, I think I fixed your resolveNode syntax. Give it a try.

for (var i = 0; i < myArray.length; i++) { 
      if (xfa.resolveNode("VISITORINFO[" + i +"]").rawValue == null){
           b = xfa.resolveNode("VISITORINFO[" +
i +"]").caption.value.text.value;
           x = "BAD";

          app.alert (x);
           }
      else
      {
      if (x != "BAD"){
           x = "GOOD" ;
          app.alert (x);
     }
      }

}

Good luck!

Stephen