# Hide Submit button on form based on field value for the logged in user

**URL:** <https://forums.knack.com/t/hide-submit-button-on-form-based-on-field-value-for-the-logged-in-user/12689>\
**Category:** Get Answers\
**Created:** [June 18, 2022, 11:44pm UTC](https://forums.knack.com/t/hide-submit-button-on-form-based-on-field-value-for-the-logged-in-user/12689 "2022-06-18T23:44:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@Justin](https://forums.knack.com/u/Justin)\
**Post date:** [June 18, 2022, 11:44pm UTC](https://forums.knack.com/t/hide-submit-button-on-form-based-on-field-value-for-the-logged-in-user/12689/1 "2022-06-18T23:44:11Z")

</div>

I’m building an employee reward store inside my app. The reward store portion of the application uses three main objects:

- Employee (User object)
- Reward (An object that contains details of the reward including cost, quantity, etc)
- Purchase (A record created to track the order and update the inventory on the Reward object, and point value on the Employee object.

Everything seems to be working correctly, but I seem unable to limit a users ability to purchase an item when they do not have available “points”. (Please note that I am not using an e-comm component). I have been unable to find a way to limit the submit button based on the criteria of available “points” the user has.

Example: User has 5 reward points, and should be unable to “purchase” an item that requires 10 reward points.

Has anyone worked with something similar or have suggestions on how I could either eliminate the form option, or hide the submit or action button?

---

<div class="post-metadata">

**Author:** ![KnackPros](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/knackpros/32/807_2.png) [@KnackPros](https://forums.knack.com/u/KnackPros)\
**Post date:** [June 19, 2022, 6:49pm UTC](https://forums.knack.com/t/hide-submit-button-on-form-based-on-field-value-for-the-logged-in-user/12689/2 "2022-06-19T18:49:25Z")

</div>

Hi,

I suggest hiding the entire form, rather than only the submit button. You can hide the entire form using [Page Rules](https://learn.knack.com/article/zplf1gfk5m-page-rules). You would create a rule that hides the form when the user doesn’t have enough points.

To hide only the Submit button based on a field value in the logged-in account, you’ll need to write custom JavaScript. The code would be similar to this (untested):

```auto
// Change "view_1" to the view you want to listen for
$(document).on('knack-view-render.view_1', function(event, view, data) {
  // Do something after the view renders
  const pointsNeeded = data.field_1
  const availablePoints = Knack.getUserAttributes().values.field_2 
  const $submitButton = $(`#${view.key} button[type="submit"]`)

  if (availablePoints < pointsNeeded) {
    $submitButton.hide()
  }

});

```
