[Javascript] regex example & code sample

Chris T christ at saeweb.com
Fri Apr 30 14:02:49 CDT 2004


> 1.  Without passing any parameters, I would have to make a separate copy
of
> this function for other forms which would use it.  It has been designed
> in this case to be "tacked on" to a page over which I have no control of
> the form or naming conventions of the text boxes.  So I have to pass the
> text box names, and I have to pass the form somehow, in order to allow for
> a document with multiple forms.  As is, this .js can be referred to by any
> number of pages.

That's why I specifically mentioned that in looking at it's possible uses,
you can narrow this down. How many places on a well-designed site will allow
you to change Password information? I can't think of any reason there will
be more than 1.  And this is obviously tied to one instance since I see
you're blocking certain brand names. In its current state, this isn't a
script that is readily avaiable to be placed on just any site.



> 2.  While using "eval" may not be the prettiest or best way, I really
> wouldn't get anything out of changing it in *this* case because
> I have no need to manipulate the form or any of its contents in this case.
> Again, because I'm not really supposed to be doing anything
> aside from giving a "helping hand" to the password change page provided by
> a third party.

You're correct that in *this* instance it doesn't serve a purpose, but
you're still needlessly limiting yourself.

And if there is one thing more important than actual syntax when it comes to
business logic is to NEVER expect that what you create now will never need
to change.

Sometime's an employer's logic is more convoluted than the actual business
logic. They'll tell you to do one thing, insisting it will never change, but
once you're around long enough, you'll have learned that you almost always
have revisit something to modify it.

Chris Tifer




More information about the Javascript mailing list