Hide HTML form if JS isn't enabled ? Can it be done ?

Started by MoreBloodWine, December 31, 2014, 02:18:58 PM

Previous topic - Next topic

MoreBloodWine

I tried diff search terms but couldnt seem to find what I wanted. Anyway, I was wondering if it's possible to somehow include the below form inside of <script></script> tags so if the users browser has JS disabled then the forum wouldn't show.

<form method='post' action=''>
<input type='text' name='address' size="40" />
<input type='submit' name='submit' value='Continue' />
</form>


So with the form hidden assuming the user has JS disabled this would otherwise show in its place.

<noscript>
You have JavaScript turned <b><font color="#FF0000">OFF</font></b> !<br />Please turn it on if you wish to participate.
</noscript>


Ty.
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


riou

you should be able to use CSS in the head section like

<noscript>
    <style>
        code for form here { display:none; }
    </style>
</noscript>

MoreBloodWine

Quote from: riou on January 01, 2015, 01:10:38 AM
you should be able to use CSS in the head section like

<noscript>
    <style>
        code for form here { display:none; }
    </style>
</noscript>

I'm not even sure what to code to get what I want.
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


Arantor

Um.... no.

You hide the entire form in CSS by setting that form to display:none, then  re-show it with JavaScript. Give the form an id, <form id="myform">

Then CSS:
#myform { display: none }

Then after the form, something like this:
<noscript>This page needs JavaScript</noscript>
<script>document.getElementById('myform').style.display = 'block';

MoreBloodWine

Quote from: Arantor on January 01, 2015, 06:00:28 AM
Um.... no.

You hide the entire form in CSS by setting that form to display:none, then  re-show it with JavaScript. Give the form an id, <form id="myform">

Then CSS:
#myform { display: none }

Then after the form, something like this:
<noscript>This page needs JavaScript</noscript>
<script>document.getElementById('myform').style.display = 'block';

Thx again Arantor !
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


Advertisement: