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?

Avatar

Avatar
Level 1
ZZ47862895
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
ZZ47862895
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
ZZ47862895
Level 1

11-05-2018

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";

}

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

14-05-2018

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

Avatar

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
MinusZero
Level 4

13-05-2018

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.