Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder durangod's Avatar
    Join Date
    Nov 2010
    Location
    East Texas USA
    Posts
    2,068
    Thanks
    349
    Thanked 57 Times in 55 Posts

    Enable submit button when js is enabled

    Hi,

    i decided to set my input submit button on my form to disabled by default and then re-enable it if js is enabled. I have tried several versions of this but cant seem to get it to work..

    Code:
     <button type="submit" name="submit" class="btn btn-primary btn-lg float-right" id="submit" disabled>Apply</button>
    
    <script type="text/javascript">
    $(document).ready(function() {
    $(':input[type="submit"]').prop('disabled', false);
    });
    </script>

    this should work as is right ? ERROR: ReferenceError: $ is not defined


    UPDATE: i got it... got away from jquery and just normal js worked perfectly


    winner!
    Code:
    <script type="text/javascript">
    document.getElementById("submit").disabled = false;
    </script>
    Last edited by durangod; Oct 1st, 2018 at 04:34 PM.
    If a php file only has php code within it you do not need to use the closing php tag
    A good way to remember objects from arrays is you shoot objects with arrows Example: $name->id; then Arrays are $name['id'];
    durangod is short for durango dave

  2. #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Location
    Here
    Posts
    3,845
    Thanks
    58
    Thanked 690 Times in 685 Posts
    "$ is not defined" tends to point to the jQuery file not being present at the time it is being referenced.

    "disabled" is an attribute in html, not a property. I know that jQuery had some confusion about that in the past but surely they have figured it out by now?


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •