Skip to main content
Topic: Disable SUBMIT button on Submit.  (Read 2023 times) previous topic - next topic

Disable SUBMIT button on Submit.

I'd like to include JS on submitting to disable Submit button so some impatient users don't add multiple entries.

I am fine doing this on a static page but not within the PHPRad.

$('form#id').submit(function(){
    $(this).find(':input[type=submit]').prop('disabled', true);
});

Any ideas?


Re: Disable SUBMIT button on Submit.

Reply #1
@HugeG‍ you can use the below codes. Please note that 1. The code you were using was not correct, phprad does not generate and id called id. And 2. PHPRad does not use input with type submit in its forms, rather PHPRad uses a button that has type submit. And also when you get codes from the internet, try to understand them so that you know how to properly use them in your phprad projects.
Use the below code to target a specific form.
Code: [Select]
$('form#{table-name}-add-form').submit(function(){
    $(this).find(':button[type=submit]').prop('disabled', true);
});
In the above code replace {table-name} with the name of the table where the page you are working on exist.
And use the below code to apply it to all forms(i.e to target all form submit button).
Code: [Select]
$('form').submit(function(){
    $(this).find(':button[type=submit]').prop('disabled', true);
});

Re: Disable SUBMIT button on Submit.

Reply #2
Thank you very much for the snippet, I see you like to "educate" your customers on other topics aswell.
Could you start by fixing the bugs in your software and drop the attitude a bit?