Skip to main content
Question

Required Fields Not Validating on Edit Form with Custom Save Button

  • Jan 4, 2025 8:00 AM UTC
  • 4 replies
  • 144 views

Forum|alt.badge.img+1

I have required fields in one of my forms. I'm using a custom button to save the form. When I click the "Save" button, it checks for the required fields in the Add Form, but it doesn't perform the validation in the Edit Form.

How can I ensure that required field validation works on the Edit Form as well when using the custom save button?

This is the custom button formula:

// Define the container style
var text container = 
    "display: flex;" &              // Use flexbox layout for arranging children
    "justify-content: center;" &    // Center all child elements horizontally
    "gap: 17px;";                   // Add space between child elements

// Define the subcontainer style
var text subcontainer = 
    "display: flex;" &              // Use flexbox layout for subcontainer
    "justify-content: center;";     // Center all child elements horizontally

// Define the button container style
var text buttonContainer = 
    "width: 130px;" &               // Set fixed width for the button container
    "display: flex;" &              // Use flexbox layout
    "flex-direction: column;" &     // Stack buttons vertically
    "gap: 10px;" &                  // Add space between buttons
    "padding: 5px 3px;" &           // Add inner spacing (5px top/bottom, 3px left/right)
    "border-radius: 8px;";          // Round the container's corners

// Define the orange button style
var text orangebutton = 
    "border-radius: 40px;" &        // Fully round the button's edges
    "color: #ffffff;" &             // Set the button's text color to white
    "background-color: #f8761f;" & // Set the button's background to orange
    "font-family: Roboto, sans-serif;" & // Use Roboto font with sans-serif fallback
    "font-weight: 700;" &           // Make the text bold
    "font-size: 12px;" &            // Set the text size
    "padding: 12px 40px;" &         // Add spacing inside the button (12px vertical, 40px horizontal)
    "display: inline-block;" &      // Ensure the button behaves like an inline-block element
    "line-height: 20px;" &          // Set the line height for text
    "text-decoration: none;" &      // Remove underline from the button text
    "text-align: center;";         // Center the text inside the button
   
// Define the black button style
var text blackbutton = 
    "border-radius: 40px;" &        // Fully round the button's edges
    "color: #ffffff;" &             // Set the button's text color to white
    "background-color: #252525;" & // Set the button's background to black
    "font-family: Roboto, sans-serif;" & // Use Roboto font with sans-serif fallback
    "font-weight: 700;" &           // Make the text bold
    "font-size: 12px;" &            // Set the text size
    "padding: 12px 40px;" &         // Add spacing inside the button (12px vertical, 40px horizontal)
    "display: inline-block;" &      // Ensure the button behaves like an inline-block element
    "line-height: 20px;" &          // Set the line height for text
    "text-decoration: none;" &      // Remove underline from the button text
    "text-align: center;";        // Center the text inside the button
    

// Define the Record ID or placeholder if not available
var text rid = 
    If([Record ID#] > 0,            // Check if a Record ID exists
        ToText([Record ID#]),       // Use the existing Record ID
        "%%rid%%"                   // Placeholder for new records
    );

// Define the close window URL
var text closewindow = URLRoot() & "db/" & AppID() & "?a=dbpage&pageid=11"; // URL to redirect to page 11 after an action, which closes the popup page

// Construct the Submit URL
var text Submit = 
    URLRoot() & "db/" & Dbid() &                // App root and database ID
    "?a=API_EditRecord&rid=" & $rid &           // API call to edit a record using Record ID
    "&_fid_23=" & URLEncode("Pending FP&A Approval") & // Update status field with "Pending FP&A Approval"
    "&_fid_25=2" &                              // Update field 25 with value 2
    "&_fid_26=1" &                              // Update field 26 with value 1
    "&rdr=" & URLEncode($closewindow);          // Redirect to the close window URL after editing

// Construct the HTML structure
"<div style='" & $container & "'>" &           // Outer container with flexbox layout
    "<div style='" & $subcontainer & "'>" &    // Subcontainer centered within the outer container
        "<div style='" & $buttonContainer & "'>" & // Button container for Cancel button
            "<a  style='" & $blackbutton & "' href='" & $closewindow & "'>Cancel</a>" & // Cancel button styled as black
        "</div>" & 
        If([Payment Request Status] = "New",   // Conditional logic for Submit or Save button
            "<div style='" & $buttonContainer & "'>" & // Button container for Submit button
                "<a class='SaveBeforeNavigating' data-replaceRid=true style='" & $Orangebutton & "' href='" & $Submit & "'>Submit</a>" &
            "</div>",
            "<div style='" & $buttonContainer & "'>" & // Button container for Save button
                "<a class='SaveBeforeNavigating' data-replaceRid=true style='" & $Orangebutton & "' href='" & $closewindow & "'>Save</a>" &
            "</div>"
        ) &
    "</div>" & 
"</div>"

This is the code page content:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script>
  window.close();
</script>
<body>

</body>
</html>

Any help would be greatly appreciated!

4 replies

MarkShnierYou
Forum|alt.badge.img+24

Are these required fields on the child tables or on the parent record?


Forum|alt.badge.img+1

They are in the parent record.


Forum|alt.badge.img
  • Registered
  • Apr 30, 2025 1:34 AM UTC

Did you ever figure this out? I'm trying to do the same!


Top Step
Forum|alt.badge.img+9
  • Registered
  • Oct 30, 2026 8:46 PM UTC

Rather than counting on the form’s required setting, I’d enforce it at the table with a custom data rule. Those run on every save, including the API_EditRecord your Submit button makes, so nobody can get past them.

 

In the table’s Advanced Settings, add a rule like this (swap in your field names):

 

If([Payment Request Status] = "Pending FP&A Approval" and Trim([Cost Center]) = "", "Cost Center is required before you submit.")

 

Your Submit button sets the status to Pending FP&A Approval, so the rule only kicks in at that moment. Normal saves while the request is still New go through. The Save button can stay as it is.

 

The error shows up on the API response instead of next to the field, so make the message clear about what’s missing.

 

Want more detail? I wrote a full walkthrough here: https://www.topstep.tech/blog/quickbase-required-fields-custom-submit-button-data-rule