SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Oct 2005
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face The usual JavaScript check doubt, now how many times has this been asked?

    Alright,

    A website I am working on uses several JavaScript for several form validations, I would rather restrict the website for only those with JavaScript Enabled for now and will worry about accessibility when interest picks up. What I am doing here is re-direct users with no JavaScript support to a page which explains how to enable JavaScript.

    How can achieve this? <nostript>? if so the best way to use no script? any other ways? do suggest

  2. #2
    Floridiot joebert's Avatar
    Join Date
    Mar 2004
    Location
    Kenneth City, FL
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Javascript is almost always enabled unless it's been disabled by someone who already knows how to enable it.

    In the case that the user isn't the one that disabled the Javascript, they almost always don't have the required privledges to enable it.

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    re: Dealing with Javascript enabled/disabled users

    What you could do is have a teaser page that is in basic HTML and redirect the user from that page using Javascript (which will fail if they do not have it enabled).

    Another option is to include

    HTML Code:
    <noscript>You do not have Javascript enabled</noscript>
    somewhere near the top of your page.

    Dave

  4. #4
    SitePoint Zealot
    Join Date
    Oct 2005
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Javascript is almost always enabled unless it's been disabled by someone who already knows how to enable it.

    In the case that the user isn't the one that disabled the Javascript, they almost always don't have the required privledges to enable it.
    Thanks, but as said logic has anything to do with this. Its merely redirecting to a page that says - JavaScript must be enabled, with a simple info.

    Ok, dwees. But simply displaying that doesn't solve the problem I am afraid. As the user can still click submit and post the form data which may be full of unvalidated errors...

    So I wonder if I can use php's header() in noscript tag? Umm.. php is server side, so most likely no I guess.

    I cant test it until I get home.

  5. #5
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't ever rely solely on the client to validate information that is
    going to a server- use the javascript as an aide, if present,
    to prompt the user or pre-format the post data,
    but always re-validate input before processing on the server.

  6. #6
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, you should always, always validate forms server-side even if you use a JavaScript validator too. Failing to do so can lead to big trouble, since it would be a big security hole.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  7. #7
    SitePoint Zealot
    Join Date
    Oct 2005
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh alright then, I have been thinking. JavaScript as a client script visitors can see the code via page source too.. so I cant have that. But still I will use a combination of both JS and PHP server side validation even though it means more time coding *sigh* ..wonder if I will ever get this project done by X'mas .

    Thanks guys.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •