Unless you're in an environment where you can count on people having JavaScript enabled, you will still have to do input validation on the server. (Even then, I wouldn't trust the client and would perform validation anyway.)

In my opinion, just about the only reason to use JavaScript is to improve the rather poor UI available with the standard HTML widgets. With a bit of client-side scripting, you can autofill boxes, bind buttons to functions, and make things slightly easier. As an example, consider the Message Inbox at Everything2. If you hit a 'Reply' button next to a private message, it fills in a textbox with the commands to respond to the sender and gives that textbox focus, so you can start typing immediately.

Even better, if you have the 'autofill' checkbox enabled, and are using a newer browser than Netscape 4.7x, you can simply run the mouse cursor over the comment and it will autofill the box.

It's also possible to send extra data to the web browser with a module like WDDX and update available selections on the client side.

Just beware -- this does not make user data any more secure, and it should degrade gracefully, unless you can guarantee that nearly all users will have JavaScript enabled for your site. (Private intranet site? Yes. Public? Probably not.)


In reply to Re: Perl vs. Javascript by chromatic
in thread Perl vs. Javascript by CiceroLove

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.