Jump to content

[SOLVED] Disable Submit button


jaymc

Recommended Posts

I want to run some javascript on my index page to monitor every submit button so that when its pressed it disables so a user can keep clicking it

 

I know I can do this using an ONCLICK, but I dont want to add this to every submit button

 

I want to put it in my master .js file to apply to any submit button on the page

Link to comment
Share on other sites

You would still need to have this in a submit button:

<input type="submit" name="submit" id="submit" onclick="javascript: disableSubmit(this);" />

 

Then have the appropriate javascript. But you would need to specify it in each one, as far as I know.

Link to comment
Share on other sites

I want to run some javascript on my index page to monitor every submit button so that when its pressed it disables so a user can keep clicking it

 

I know I can do this using an ONCLICK, but I dont want to add this to every submit button

 

I want to put it in my master .js file to apply to any submit button on the page

 

Well, like vikramkeet.singla said, you can filter out the submits by CSS class.  It's easiest to use jQuery for this:

$(".yourClassName").click(function()
{
   //do whatever you want here
});

 

So, give your submits a class to replace 'yourClassName' and fill out the body of the onclick callback function.  That will attach that onclick callback to every element of that class.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.