Posted by manuj_78 on August 7, 2010 at 12:51pm
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
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.jsselector..foo {display: none;
}
html.js .foo {
display: block;
}
Drupal adds the
.jsclass dynamically when javascript is enabled. If it is not enabled, then this class does not exist.Or you can add a hidden input form
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.