6

I was checking out a form I made on my iPad and it appears that adding disabled to a <button> tag doesn't actually disable the button.

Adding disabled to an <input> tag works but not <button>.

So

<input type = "text" disabled />

works, but

<button disabled>Hola</button>

doesn't. Thoughts on ways to fix this? Or is it just a safari bug?

1
  • Can this possibly still be true in 2022? Commented Feb 18, 2022 at 14:24

3 Answers 3

4

You can use the disabled attribute on an <input /> tag but not a <button /> Tag. Button isn't officially depreciated but because you can do

<input type="submit" value="Click Me">

for form submission capabilities and

<input type="button" value="Click Me">

for a generic plain-old button there is no real point to having a whole different tag. Furthermore you can disable both a submit and a regular button by adding disabled

<input type="submit" value="You can't Click Me" disabled>
<input type="button" value="Click Me" disabled>
Sign up to request clarification or add additional context in comments.

2 Comments

This is an old answer, but it appears disabled is fine to use with <button> now.
Nope, disabled is not working now in mobile.
3

This iOS Safari bug is terrible. Does the IPad support the blink tag? As far as I know you really can't style <input>'s like you can <button>'s. So if you have a <button> with <span>'s that are styled or <img>'s in side that button, <input> is not the way to go. Instead fake it, make your button behave like it has the attribute 'disabled'.

Add a class to your button:

<button class='ipad-disabled'></button>

Then check to see if that button has that class of 'ipad-disabled', If it does, nothing will happen when you click that button:

$('button').on('click', function () {
    if (!$(this).hasClass('ipad-disabled')) {
        doSomething(this);
    }
});

Then when you need the <button> to be enabled remove the 'ipad-disabled' class:

$('button').removeClass('ipad-disabled');

Comments

0

I checked this on my residential iPad. You're right that the button tag doesn't work, but these do:

<input type="button" value="Go on, click me!">

and

<input type="submit" value="Go on, click me!">

I hope that solves your problem. Anything you can do with a <button></button>, you can do with an <input type="button"> or <input type="submit">. It must be an iOS Safari bug.

EDIT:

Button does accept disabled in Chrome, so I blame Safari on iOS.

EDIT:

See Fiddle.

3 Comments

I didn't think much of it but a friend mentioned it to me and I started to look into it and it does indeed appear to be a full blown bug. No one else is really talking about it or so it seems. I know you can just use <input type = 'button' /> but this seems like a rather simple feature to have in your browser. Ya know, being compliant with features that were established many many years ago.
@Nick Chapman It's rather unfortunate that in our connected age on the internet (which is magical), we still have to worry about browser compatibility. But, we do. So, you can either just ignore those stupid browsers that screw up or you can try and accommodate them. Typically, the best solution is a compromise. You shouldn't waste your time trying to support Elinks, but do worry about IE because a lot (too many) people still use it.
I hope all of this helps. If you're doing something with disabled buttons, it's best to stick with <input type="button or submit" etc...> because, as you see, iOS Safari somehow manages to break it. I'll come back tommorow (EST) if you have any further issues/questions. Until then, good night!

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.