Javascript form when user's browser has it disabled

If i have a javascript signup form for my website, what happens if a user tries to signup if they Disabled javascript in their browser settings? Will the javascript signup form just be a blank space?
Is there anyway to display a message like “you need to enable javascript to use this website” if a user’s browser has javascript disabled? Any tutorials?

It depends on how you’ve set things up, but most likely they will see the HTML form (unless it’s generated by JS, which is unlikely), but it won’t send anything.

It’s better to use PHP for processing the form, and to add JS enhancements that are not critical.

Is there anyway to display a message like “you need to enable javascript to use this website” if a user’s browser has javascript disabled? Any tutorials?

You can use <noscript> tags, which display a message if JS is disabled. (Just Google “noscript”.) But it’s not a very nice message to receive, and it’s better not to lock out visitors like this. Aim for critical features to be accessible by all.

Ah, I agree, “noscript” tags might be your best option (more info: http://www.w3schools.com/TAGS/tag_noscript.asp )

The noscript tag serves no useful purpose any more since it can only tell whether javaScript is enabled or not and can’t tell whether the JavaScript you want to run is supported or not. You will end up with shorter code if you simply leave out the noscript tags and use JavaScript to hide that content when the script is supported.

The w3schools website is several years out of date with its pages on JavaScript.

considering the dude asking the question asked how to display some other content if (and I quote): “a user’s browser has javascript disabled”, and you said (and I quote): “The noscript tag serves no useful purpose any more since it can only tell whether javaScript is enabled or not”, it looks like the noscript tag serves exactly, no more and no less, the purpose of what he’s trying to achieve.

Looks like you are answering a different question? as, maybe I’m reading it wrong, the dude up there doesn’t want to just hide its content when the script is not supported, he wants to display different content

The content for when JavaScript is disabled just goes in the HTML. No special tags required but it there may be parts that need to have an id to make them easier to reference from JavaScript.

Then from the JavaScript you can reference the ids to remove the content you don’t want visible when JavaScript is disabled and to add the content you want there when JavaScript is enabled.

Since noscript is a block level element and only detects when a browser doesn’t support JavaScript using it just makes the code longer ,less accurate as well as non-semantic.

Anything that you can do using noscript you can do from JavaScript without a need for noscript. For example:


<p id="a">This is what displays when JavaScript is disabled.</p>
<script type="text.javascript">
document.getElementById('a').innerHTML = 'Completely different content when JavaScript is enabled.';
</script>

Yes, you are right :slight_smile:

I’m assuming he doesn’t know too much javascript, as the real solution is that his signup form should work without javascript anyway.

Your suggestion is really the most logical, and the best, if he knows a bit of javascript. The noscript is the easiest if he doesn’t know too much about what he’s doing.