# Disabling Button

**URL:** <https://forum.wixstudio.com/t/disabling-button/18047>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [June 18, 2019, 10:55am UTC](https://forum.wixstudio.com/t/disabling-button/18047 "2019-06-18T10:55:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![wixcanada95](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@wixcanada95](https://forum.wixstudio.com/u/wixcanada95)\
**Post date:** [June 18, 2019, 10:55am UTC](https://forum.wixstudio.com/t/disabling-button/18047/1 "2019-06-18T10:55:55Z")

</div>

I’m trying to disable a button based off of previous form submissions, for some reason the button remains enabled.

```javascript
$w.onReady( function () { 
    user.getEmail() 
        .then((email) => { 
 let userEmail = email // "user@something.com"    
wixData.query("Events") 
                .eq('usernameEmail', userEmail) 
                .count() 
                .then((num) => { 
 let nos = num; 
                    $w("#submittedsofar").value = num; 
                    $w("#eventsdatasetsubmission").setFieldValue('eventNumber', $w("#nos").value); 
                    $w("#remainingnos").valu`Preformatted text`e = ($w("#initialnumber").value) - ($w("#submittedsofar").value); 
                    $w("#eventsdatasetsubmission").setFieldValue('remainingSubmissions', $w("#remainingnos").value); 
 
if ($w("#remainingnos").value > 0) { 
                        $w("#buttonStart").enable; 
                        $w("#startmessage").show; 
                    }  

else { 
                        $w("#buttonStart").disable; 
                        $w("#startmessage").hide; 
                    } 
                }) 
        }) 
})

```

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [June 18, 2019, 12:06pm UTC](https://forum.wixstudio.com/t/disabling-button/18047/2 "2019-06-18T12:06:56Z")

</div>

The value in an input field is a **string** and not a **number**.

This:  
**if ($w("** [**#remainingnos**](https://www.wix.com/corvid/forum/search/~num~remainingnos) **").value \> 0) {**

should be something like this:  
**if (Number($w("** [**#remainingnos**](https://www.wix.com/corvid/forum/search/~num~remainingnos) **").value) \> 0) {**

---

<div class="post-metadata">

**Author:** ![wixcanada95](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@wixcanada95](https://forum.wixstudio.com/u/wixcanada95)\
**Post date:** [June 18, 2019, 10:34pm UTC](https://forum.wixstudio.com/t/disabling-button/18047/3 "2019-06-18T22:34:21Z")

</div>

It still isn’t working for some reason.

---

<div class="post-metadata">

**Author:** ![givemeawhisky](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/givemeawhisky/32/5383_2.png) [@givemeawhisky](https://forum.wixstudio.com/u/givemeawhisky)\
**Post date:** [June 19, 2019, 2:40pm UTC](https://forum.wixstudio.com/t/disabling-button/18047/4 "2019-06-19T14:40:41Z")

</div>

Why are you still posting multiple posts about the same question 😵

[https://www.wix.com/corvid/forum/community-discussion/enabling-disabling-button-using-if-then-login](https://www.wix.com/corvid/forum/community-discussion/enabling-disabling-button-using-if-then-login)

---

<div class="post-metadata">

**Author:** ![emanu2000](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/emanu2000/32/26771_2.png) [@emanu2000](https://forum.wixstudio.com/u/emanu2000)\
**Post date:** [June 21, 2022, 3:19am UTC](https://forum.wixstudio.com/t/disabling-button/18047/5 "2022-06-21T03:19:56Z")

</div>

try this

$w(“#buttonStart”).disable();

---

<div class="post-metadata">

**Author:** ![Rob](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/rob/32/84134_2.png) [@Rob](https://forum.wixstudio.com/u/Rob)\
**Post date:** [June 25, 2025, 2:45pm UTC](https://forum.wixstudio.com/t/disabling-button/18047/6 "2025-06-25T14:45:37Z")

</div>

I was going through the forum and came across this and noticed you had some incorrect syntax like emanu2000 mentioned - in that you were missing the () on enable, show, disable and hide.

You don’t use parenthesis if you’re referring to states like **[enabled](https://dev.wix.com/docs/velo/velo-only-apis/$w/button/enabled)**, which is checking the enabled _property_ status of in this case a button, but you do in a function like **[enable()](https://dev.wix.com/docs/velo/velo-only-apis/$w/button/enable)**, which turns the _property_ to **true** and enables the button so users can interact with it.

I didn’t test the code outright since I was unsure of the setup of the collections but it should look more like this:

```javascript
$w.onReady(function () {
    user.getEmail()
        .then((email) => {
            let userEmail = email; // e.g., "user@something.com"
            wixData.query("Events")
                .eq("usernameEmail", userEmail)
                .count()
                .then((num) => {
                    // Update the value of #submittedsofar
                    $w("#submittedsofar").value = num;

                    // Calculate remaining submissions
                    let initialNumber = $w("#initialnumber").value; // Ensure this element exists and has a value
                    let remainingSubmissions = initialNumber - num;

                    // Update the dataset fields
                    $w("#eventsdatasetsubmission").setFieldValue("eventNumber", num);
                    $w("#eventsdatasetsubmission").setFieldValue("remainingSubmissions", remainingSubmissions);

                    // Update the value of #remainingnos
                    $w("#remainingnos").value = remainingSubmissions;

                    // Enable or disable the button based on remaining submissions
                    if (remainingSubmissions > 0) {
                        $w("#buttonStart").enable();
                        $w("#startmessage").show();
                    } else {
                        $w("#buttonStart").disable();
                        $w("#startmessage").hide();
                    }
                });
        });
});

```

---

<div class="post-metadata">

**Author:** ![noahlovell](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/noahlovell/32/118920_2.png) [@noahlovell](https://forum.wixstudio.com/u/noahlovell)\
**Post date:** [June 25, 2025, 3:37pm UTC](https://forum.wixstudio.com/t/disabling-button/18047/7 "2025-06-25T15:37:08Z")

</div>

Closed on June 25, 2025, 3:37pm UTC


