HyperTextMatters
19 April 2006
 
Ajax Hacks Butchers Javascript
Post a comment (login required)
Javascript programming has finally come to be considered enterprise-ready due to the advent of Ajax.  Sadly though the Oreilly "Ajax Hacks" book threatens to reverse this upsurge in Javascript understanding.  Case in point is "Hack 22. Validate a Text Field or textarea for Blank Fields."  The author naively suggests you check form field values in a boolean context such as "if (this.value) .... "  I'd not encountered this particularly egregious faux pas in a book in a couple of years; such "validation" code is easily circumvented by entering spaces.  You should actually check for any non-whitespace characters with a regular expression such as "if (/\S/.test(this.value)) ...."  Shame on OReilly for letting this get to print and potentially undoing the current Javascript renaissance.
Posted by htmatters at 6:59 PM | Comments (0)
 
Subscription Options

You are not logged in, so your subscription status for this entry is unknown. You can login or register here.

No comments found.

Post a comment (login required)