1 Reply Latest reply on Apr 21, 2006 8:41 AM by BSterner

    CFFORM regex Problem

      I'm trying to restrict a form value to something like mm/dd as follows:

      <cfinput type="text" name="AnStartDate#i#" id="AnStartDate#i#" validate="regular_expression" pattern="^[0-1]?[0-9]/[0-3]?[0-9]*$" size="4" maxlength="5" validateat="onSubmit" message="Please enter all annual start dates as mm/dd" />

      The form loops to give a total of 5 rows of text entries.

      When the page loads, Firefox's Javascript console shows the following error:

      Error: syntax error
      Source File: http://localhost/mti/orders/refurb/edit_duty.cfm?type=Argos%2FGPS%20Solar%20PTTs&prodID=79
      Line: 196, Column: 92
      Source Code:
      if (!_CF_checkregex(_CF_this['AnStartDate1'].value, /^[0-1]?[0-9]/[0-3]?[0-9]*$/, true))

      with the arrow indicating the error is right before the "true" at the end of the statement.

      Since this is in the JS generated by CF, is there a problem in the regular expression? I want the initial digit of the month or day to be optional, so users can type, "6/4" rather than "06/04" but it needs to be no more that 5 characters, and look like a date without a year. Right now, because of the error, anything is accepted.
        • 1. Re: CFFORM regex Problem
          You need to escape your "/".


          Just an FYI, the only thing this is validating is that you have 1 or 2 digits who's value is lte 19 followed by a "/" followed by one or 2 digits who's value is lte 39. The values 19/39 or 00/00 would pass the test despite the fact they're far from being a valid date.