0

How do I disable element so it will not submit when clicking on it (but make sure javascript events still work)? "Disabled" attribute turns javascript off.

2 Answers 2

1

Add return false; to the Javascript event handler.
(or e.preventDefault(); e.returnValue = false;)

Sign up to request clarification or add additional context in comments.

2 Comments

I did this but there was no effect.
Oh it works now. The only thing I needed to figure out myself was place a word return before the javascript function name in html attribute onClick.
1

Another option is to not make it a submit button

<input type="button" value="Button Text" onclick="myHandler()" />

1 Comment

The problem is my element is <IMG> and not a button.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.