in reply to Regex help

Our forms (here at work) utilize javascript for limiting text. I don't think there is a perl way to do this.

despite my reservations, I am gonna post non-perl code (at least it's generated by perl).

this is a js routine that will handle it...

function checkTextAreaLen( fName, theField, maxLen ) { if ( theField.value.length > maxLen ) return msgErrorMid( fName, theField, maxLen, "Please enter less th +an ", " characters into the \"", "\" field. \nCurrently there are " + + theField.value.length + " characters in the field." ); return true; } ## and here is the onChange that invokes it from a textarea, limiting + to 1500 chars onChange="checkTextAreaLen(gsJobdesc,this,1500)

now I have to find a way to purge away the sin I have committed...suggestions are welcome

Replies are listed 'Best First'.
Re: Re: Regex help
by thraxil (Prior) on Jun 16, 2001 at 02:55 UTC

    you really ought to doublecheck the length on the server too if that's in a form that gets submitted. a user may have javascript turned off, or, if your systems would break on too much input, a (cr|h)acker might manually send you longer input as a DOS.

    point is, you should never rely on client-side code to validate forms.

    anders pearson // digital samurai
    personal      // http://www.columbia.edu/~anders/
    weblog       // http://thraxil.dhs.org/
    
      point is, you should never rely on client-side code to validate forms.

      I wholehearetdly agree, our use of javascript in this case is to just to prevent a post if the length is out of bounds with a textarea. when the form gets posted, the real validations take place (a fun place where MS word formatting characters are sanitized and fed to oracle) via perl. We also handle forcing/restricting alpha/numerics, etc I inherited the system (on contract), but given the user requirements, I can't see how it could have been done any other way. (the requirements were specifically for popup warnings, which while annoying save posts to the busy server)

      btw, this being an internal business app, we have only have to code to one browser, netscape 4.x and require javascript. a very controlled environment. there are plenty of other reasons on top of what we're discussing that would disqualify it for general net use. :-)