This topic is locked

Why doesn't this work Hide Sections, and control validation behaves different in Chrome Vs Edge

10/1/2025 13:20:47
ASPRunner.NET General questions
M
MSchell author

ASPRunner.net Enterprise Build 43785

This code is in the Edit Page JavaScript OnLoad event.

Based on the saved data, it will hide or show differet sections of the edit page. I know it's making it into the if statement because I inserted this: "RelocationPerDiemComments.setValue(proxy.Pos_FilledOutsidePosting);" to place the value in this field, and it is doing that.

if (PosFilledOutsidePosting.getValue() === 'on') {
pageObj.toggleItem("section2", true);
pageObj.toggleItem("CodeBlock", false);
pageObj.toggleItem("UnpaidVP", false);

RelocationPerDiemComments.setValue(proxy.Pos_FilledOutsidePosting);
DepartmentCode.removeValidation("IsRequired");
ResourceCode.removeValidation("IsRequired");
BusinessUnit.removeValidation("IsRequired");
EarningsCode.removeValidation("IsRequired");
PhysicalLocation.removeValidation("IsRequired");
ActivityCode.removeValidation("IsRequired");
ProjectCode.removeValidation("IsRequired");

}

Attached inages:

Edge:
VP section is hidden
Code Block not hidden but should be
fields are required but should not be
Section 2 is displayed

Chrome
VP hidden
Code Block hidden
Section 2 not displayed
Record saves so Code Block fields are not required.

chrome2025-10-01_12-12-06.png
edge2025-10-01_12-12-54.png
ChatGPT 10/1/2025

It seems like you're experiencing inconsistent behavior across different browsers (Edge and Chrome) when executing JavaScript in your ASPRunner.NET application. Let's break down the issues you’re encountering one by one:

1. Visibility of Code Block

In your JavaScript code, you're toggling the visibility of the "CodeBlock" section based on the condition:

pageObj.toggleItem("CodeBlock", false);

In Edge, it seems the "CodeBlock" section is not being hidden as expected, while in Chrome, it's hidden. Ensure that the ID "CodeBlock" is correctly referenced in both browsers and that there are no CSS styles or other JavaScript code that might override this toggle in Edge.

2. Required Fields Validation

You are removing the required validation for several fields:

DepartmentCode.removeValidation("IsRequired");
ResourceCode.removeValidation("IsRequired");
BusinessUnit.removeValidation("IsRequired");
EarningsCode.removeValidation("IsRequired");
PhysicalLocation.removeValidation("IsRequired");
ActivityCode.removeValidation("IsRequired");
ProjectCode.removeValidation("IsRequired");

If the fields are still showing as required in Edge, check the following:

  • Make sure that the removeValidation method exists and is being executed correctly in both browsers. You can add some debug logging to confirm that this code is running as expected.
  • Verify if there are any conflicting scripts or CSS that might affect the required status of these fields.

3. Consistency Across Browsers

To troubleshoot the inconsistencies:

  • Debugging: Use the developer tools in both Edge and Chrome (F12) to inspect the elements and see if the expected changes are being applied. Check the console for any errors that might indicate why things are not behaving as expected.
  • Cross-Browser Testing: Sometimes, different browsers interpret JavaScript or CSS differently. Ensure that your JavaScript code is compatible across browsers.
  • Caching Issues: Sometimes browsers cache JavaScript files. To rule this out, clear the cache or open the browser in incognito mode.
  • Browser-Specific Code: If there are any features or methods that behave differently between browsers, consider adding browser-specific checks and handling to ensure consistent behavior.

Suggested Debugging Steps

  1. Add console.log statements throughout your script to verify that all parts of the code are being executed. For example:
     console.log("PosFilledOutsidePosting: ", PosFilledOutsidePosting.getValue());
    console.log("Toggling CodeBlock visibility");

  2. Check the state of the elements after the code runs. This can help determine if the issue lies with the toggling functions or with the elements themselves.
  3. Verify that any libraries or components you are using are up to date and compatible with both browsers.

Conclusion

Start with debugging using console logs and checking for errors in the developer tools. This should give you a clearer idea of where the discrepancies are occurring and help you address the issues effectively. If the problem persists, consider reaching out to the ASPRunner.NET support community or forums for more targeted assistance based on your specific version and use case.

M
MSchell author 10/1/2025

Can't say ChatGPT was any help to me.

M
MSchell author 10/1/2025

PosFilledOutsidePosting is a bit field