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

ZZ47862895

Avatar

ZZ47862895

ZZ47862895

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

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372
_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

MinusZero

Avatar

MinusZero

MinusZero

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.