Hide submit button using Javascript
18,117
Solution 1
Why javascript when noscript will do the job:
<form>
.
.
.
<noscript>
<input type="submit" />
</noscript>
</form>
Solution 2
simple javascript,
<body onload="hideButton()">
<script>
function hideButton()
{
document.getElementById("buttonId").style.display='none';
//or you can try
//document.getElementById("buttonId").style.visibility='hidden';
}
</script>
<input type="submit" value="submit" id="buttonId" />
</body>
Solution 3
In jQuery:
$(document).ready(function() {
$('#buttonId').hide();
});
Solution 4
It is very easy to hide a submit button:
<form method="post/get" action="#">
<input type="Text" name="xyz">
<input type="submit" style="visibility:hidden">
</form>
Author by
Nyxynyx
Hello :) I have no formal education in programming :( And I need your help! :D These days its web development: Node.js Meteor.js Python PHP Laravel Javascript / jQuery d3.js MySQL PostgreSQL MongoDB PostGIS
Updated on June 04, 2022Comments
-
Nyxynyx almost 2 years
How do I hide the submit button using javascript? Reason is because my form checkboxes submits the form on click but only when JS is enabled. For those with JS disabled, I want them to see the submit button, so I want to hide the submit button using JS. I'm using Codeigniter if this helps. Thanks!
-
Ben about 13 yearsdisplay=none Will make an element act like it is removed from the DOM, so other elements around the button will then readjust themselves to fill the void (depending on their style settings). visibility=hidden acts like adjusting the element transparency to zero.
-
Nyxynyx almost 13 yearsi want those with javascript enabled to not see the button, those without to see the button.
-
mplungjan almost 13 years@Nyxynyx And that is EXACTLY what will happen with the code above. Invisible to those with JS present and enabled, visible to everyone else. Did you try it?
-
asprin about 11 yearsNecromancer. Do you even realize this has an accepted answer?