Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: CGI and JavaScript

by sierrathedog04 (Hermit)
on Jun 03, 2001 at 02:14 UTC ( [id://85236]=note: print w/replies, xml ) Need Help??


in reply to CGI and JavaScript

No one designs cars for those who wish to drive on bald tires, and there is no obligation to design web pages for those who wish to surf with Javascript turned off.

Several posters have mentioned that using Javascript for client-side form validation reduces traffic on the server significantly.

Another reason is to reduce the complexity of one's code. If Javascript catches an error client-side, everything remains as it was. If Perl catches an error server-side, then the entire form must be returned to the user as it was. (I do not think that using a browser's history mechanism to return to the form as it was submitted is reliable in all instances.)

What if the form you are processing can be submitted from several different pages? How do you know the HTML text of the page that submitted the form?

Lincoln Stein includes Javascript support in CGI.pm for a reason. I say use it for form validation if for nothing else.

Replies are listed 'Best First'.
Re: Re: CGI and JavaScript
by stuffy (Monk) on Jun 03, 2001 at 03:51 UTC
    You are suggesting using it for form validation. That makes since, but do you worry about people that don't have it turned on? How do you handle that? If someone doesn't have javascript on, are they just out of luck? In that case have you lost out on someones buisness (or has whom ever hired you lost out on someones buisness?) I understand on high traffic sites it is probably a good thing, but what about a backup plan for the people that don't have it on?

    by the way, there are cars designed for people that like to drive with bald tires, you can usually find them at the local drag strip :~)
    update: corrected spelling

    Stuffy
    That's my story, and I'm sticking to it, unless I'm wrong in which case I will probably change it ;~)

      This can be solved by checking if the user has javascript enabled, if not, pass a hidden flag then have the cgi script do it. You could so something like this.

      HTML Form <form> <noscript> <input type="hidden" name="jsenabled" value="yes"> </noscript> </form> CGI Script if ($q->param('jsenabled') eq "Yes") { #perform validation }
      -thabenksta
      my $name = 'Ben Kittrell'; $name=~s/^(.+)\s(.).+$/\L$1$2/g; my $nick = 'tha' . $name . 'sta';

        You're trusting that input is from your form, and that your form has gone unedited. Clientside .*script is helpful, but is no substitute for good practice.

        After Compline,
        Zaxo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://85236]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (7)
As of 2024-03-29 12:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found