How to stop nodes from being added when js is disabled

Events happening in the community are now at Drupal community events on www.drupal.org.
manuj_78's picture

Hi

Is there any way to prevent nodes from being added to the site if javascript is disabled?

We have some node types that make use of a lot of javascript functionality using cck, autocomplete, mapping etc
if javascript is disabled we dont want the user to be able to add nodes as it can result in data being saved in the wrong format..

Is there some access control module that I can use or some hooks etc to check if js is disabled and if it is then stop the node from being added?

Thanks

Comments

To be sure, add server side validation

markus_petrux's picture

Once you have added code to validate the form and ensure nodes cannot be saved with wrong format, then you can use the noscript tag to display a warning.

You can also use CSS to show/hide stuff depending on javascript availability using the html.js selector.

.foo {
  display: none;
}
html.js .foo {
  display: block;
}

Drupal adds the .js class dynamically when javascript is enabled. If it is not enabled, then this class does not exist.

Or you can add a hidden input form

andreiashu's picture

Yyou can add a hidden value with Javascript to your form so upon submitting the form you can check if that value exists in a validation function for the from. If the value doesn't exist you'll know that JS was disabled.

Mobile

Group organizers

Group categories

Mobile

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: