WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > IT Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

IT Discussion Forum Having IT issues? Got IT questions? Who doesn't? If you can't get your Apache to work with your MySQL or your php is choking on your ODBC... Let's see if we can help you come up with some ideas.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-25-2008, 11:51 AM
Prometheus Prometheus is offline
WebProWorld Member
 

Join Date: Aug 2006
Location: Arlington, TX USA
Posts: 31
Prometheus RepRank 0
Default How do I require JavaScript (Active Scripting)?

I need to have a form plug into javascript and if the user does not have active scripting enabled, I want it to tell them to turn on active scripting.

How do I do this? Anyone know the code?
__________________
Steve
www.gmtruckclub.com
Reply With Quote
  #2 (permalink)  
Old 01-25-2008, 02:42 PM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,648
wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: How do I require JavaScript (Active Scripting)?

Since page content can only be changed using Javascript, you should have the default page content show the error message indicating that Javascript is required. For example:
HTML Code:
<div id="jscheck">
   <p>This function requires JavaScript. You're browser does not support the Javascript functions
   used to implement this function, or JavaScript is not enabled. Please enable JavaScript on
   your browser and refresh the page.</p>
</div>
And then create a script that will replace the error message if JavaScript is enabled on the visitor's browser.

Code:
<script>
if (document.getElementById) {
   formarea = document.getElementById("jscheck");
   formarea.innerHTML = '<p>You have JavaScript enabled! Yay!</p>';
}
</script>
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog

Last edited by wige : 01-25-2008 at 02:42 PM. Reason: Forgot the closing bracket
Reply With Quote
  #3 (permalink)  
Old 01-25-2008, 04:12 PM
DaveSawers's Avatar
DaveSawers DaveSawers is offline
WebProWorld Veteran
 

Join Date: Dec 2006
Location: Calgary, Alberta, Canada
Posts: 332
DaveSawers RepRank 1
Default Re: How do I require JavaScript (Active Scripting)?

Or just use the <noscript> option, thus:

Code:
    <div id="warning"><script type="text/javascript">
    <!--
    // -->
</script>
<noscript>
<p>Your browser doesn't support JavaScript or JavaScript support has been disabled. You must enable JavaScript to use this application.</p></noscript>
</div>
__________________
Dynamic Software Development
www.activeminds.ca
Reply With Quote
  #4 (permalink)  
Old 01-26-2008, 03:21 PM
Prometheus Prometheus is offline
WebProWorld Member
 

Join Date: Aug 2006
Location: Arlington, TX USA
Posts: 31
Prometheus RepRank 0
Default Re: How do I require JavaScript (Active Scripting)?

Ok, good ideas. I think I can work with them. My issue is that I want to show most of the page regardless of JavsScript or not. If they want to submit contact information, I want them to know that they must have JS enabled as I run an inline form validator when submit is hit. I guess I can take the whole form and stick it inside the jscheck innerHTML area. I'll give it a shot.
__________________
Steve
www.gmtruckclub.com
Reply With Quote
  #5 (permalink)  
Old 01-26-2008, 03:25 PM
Prometheus Prometheus is offline
WebProWorld Member
 

Join Date: Aug 2006
Location: Arlington, TX USA
Posts: 31
Prometheus RepRank 0
Default Re: How do I require JavaScript (Active Scripting)?

A bit of background ... my issue overall is a contact form that has required fields with a JavaScript validator.

When people submit without JavaScript, they can put whatever they want or leave fields blank. We're about to do a database move and I need to make certain that the data is complete when moving over. So if I can let them see the form, but not let them submit it w/o JavaScript then that's my goal.
__________________
Steve
www.gmtruckclub.com
Reply With Quote
  #6 (permalink)  
Old 01-26-2008, 03:27 PM
carbonize carbonize is offline
WebProWorld Veteran
 

Join Date: Jul 2003
Location: Bristol, UK
Posts: 965
carbonize RepRank 0
Default Re: How do I require JavaScript (Active Scripting)?

You should always check submitted data serverside regardless of whether or not you validate it browser side using JS.
__________________
Carbonize
Reply With Quote
  #7 (permalink)  
Old 01-26-2008, 03:36 PM
Prometheus Prometheus is offline
WebProWorld Member
 

Join Date: Aug 2006
Location: Arlington, TX USA
Posts: 31
Prometheus RepRank 0
Default Re: How do I require JavaScript (Active Scripting)?

So is the true solution to find an ASP form validator?
__________________
Steve
www.gmtruckclub.com
Reply With Quote
  #8 (permalink)  
Old 01-26-2008, 04:03 PM
carbonize carbonize is offline
WebProWorld Veteran
 

Join Date: Jul 2003
Location: Bristol, UK
Posts: 965
carbonize RepRank 0
Default Re: How do I require JavaScript (Active Scripting)?

I'm not an ASP scripter but I do believe that ASP has form validation functions built in. In PHP you would have to write your own but that is simple enough.
__________________
Carbonize
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > IT Discussion Forum
Tags: active scripting, javascript



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Require Some Ideas!!!! SeoKingMan Search Engine Optimization Forum 4 12-23-2005 05:20 PM
JavaScript Remote Scripting: Building an AJAX-based Random WPW_Feedbot Graphics & Design Discussion Forum 0 10-20-2005 01:31 PM
JavaScript Remote Scripting: Processing XML Files WPW_Feedbot Graphics & Design Discussion Forum 0 10-10-2005 03:09 AM
JavaScript Remote Scripting: Reading Data From the Server WPW_Feedbot Graphics & Design Discussion Forum 0 09-24-2005 02:57 AM
php require() brendgard Web Programming Discussion Forum 3 12-15-2004 12:21 PM


Search Engine Friendly URLs by vBSEO 3.0.0