Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

How can I make two buttons either "invisible" or "visible" based on a text field being either blank or have something typed in it?

ZZ47862895
Level 1
Level 1

I am trying to make two different buttons either be visible or invisible depending on if a certain text field has something typed into it or not:

1) If the text field is left blank, I want the "SubmitToHR" button visible and the "SubmitToHRccEmp" button to remain invisible.

2) If the text field is filled in, I want the "SubmitToHR" button to be invisible, and the "SubmitToHRccEmp" button to be visible.

With the below code, number 1) works, but 2) does not (I can make the SubmitToHR button invisible, but the SubmitToHRccEmp button does not become visible. Can someone help me find out what I'm doing wrong? Based on everything I've read, I believe the code I have is correct, it just isn't working. Thank you!

form1.Page1.INVISIBLEValidationField::validate - (JavaScript, client)

//Email field validation for cc Employee

if (Page1.EmployeeEmail.rawValue == null)

{

    Page1.SubmitToHR.presence = "visible";

    Page1.SubmitToHRccEmp.presence = "invisible";

}

else if (Page1.EmployeeEmail.rawValue !== null)

{

    Page1.SubmitToHR.presence = "invisible";

    Page1.SubmitToHRccEmp.presence = "visible";

}

2 Replies
MinusZero
Level 7
Level 7

Hi,

This line could likely be your problem.

else if (Page1.EmployeeEmail.rawValue !== null)

Not is != instead of !==

You have one too many equals signs.

_Bruce_Robertson
Level 10
Level 10

Hi,

Your code looks alright to me, you could remove the whole else condition, so

if (Page1.EmployeeEmail.rawValue == null)

{

    Page1.SubmitToHR.presence = "visible";

    Page1.SubmitToHRccEmp.presence = "invisible";

}

else

{

    Page1.SubmitToHR.presence = "invisible";

    Page1.SubmitToHRccEmp.presence = "visible";

}

But that is not likely to be the problem, is Page1 flowed?  Is SubmitToHRccEmp visible by default?  Maybe if you could share a link to your form.

Regards

Bruce