Forums

Checking on ACTIVE Javascript

Roberto Cravallo 18 Mar, 2014
After having received a few forms with empty "required" fields, I was stumped.

Finally figured it out. Te users where probably using NOSCRIPT or some such. If I block JAVASCRIPT on my site, everything goes......

My question: How can I check for active JAVASCRIPT and display a message for the user. Furthermore I would like to add a message like "JAVASCRIPT was not available on this system" to my form.

Thnks for your input in advance....
GreyHead 19 Mar, 2014
Hi Roberto,

You can use <noscript> to show a message. To check if JavaScript is set on or not you could add a hidden input to your form like this:
<input type='hidden' name='javascript' id='javascript' value='off' /> 
And then add a little script to your page to change the setting:
window.addEvent('domready', function() {
  $('javascript').value = 'off';
});
or the jQuery equivalent if MooTools isn't loaded on your page.

Better is to add Serverside validation to your form. Please see this FAQ

Bob
Roberto Cravallo 19 Mar, 2014
Hi Bob,

I was looking into the server side validation, but can't find any info on how to do this correctly in CFv5. In the "Server Validation", in the not empty (I assume this to mean the field should not be empty) listbox, I added "_Anrede:Diese Feld ist ein Pflichtfeld und darf nicht leer bleiben!". Would that be correct?

Can't upload a picture to show you... ;-)
Roberto Cravallo 21 Mar, 2014
Hi GreyHead,

can't figure out how to use the script you so kindly provided and when I use the Server Side validation of CFv5, my forms behavior "messes" up.

I sent Max a form and will continue to try and figure it out myself!
This topic is locked and no more replies can be posted.