Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Button should be 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 2

In click event of CHECK FIELDS button,you can check if all the three required fields are filled.Accordingly you can make the 'Good to Go' button hidden/visible.

if(reqField1XPath.rawValue != null && reqField2Xpath.rawValue != null && reqField3Xpath.rawValue != null)

{

     //If all the the three fields are filled make the button visible

    GoodToGoButtonXpath.presence = "visible";

}

else

{

    GoodToGoButtonXpath.presence = "hidden";

}

Where reqField1XPath,reqField2XPath,reqField3XPath,GoodToGoButtonXpath should be the XPATH of the fields.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

In click event of CHECK FIELDS button,you can check if all the three required fields are filled.Accordingly you can make the 'Good to Go' button hidden/visible.

if(reqField1XPath.rawValue != null && reqField2Xpath.rawValue != null && reqField3Xpath.rawValue != null)

{

     //If all the the three fields are filled make the button visible

    GoodToGoButtonXpath.presence = "visible";

}

else

{

    GoodToGoButtonXpath.presence = "hidden";

}

Where reqField1XPath,reqField2XPath,reqField3XPath,GoodToGoButtonXpath should be the XPATH of the fields.