PHP Classes

Debugging a failed input validation

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  PHP Forms Class with HTML Generator and JavaScript Validation package blog  >  How to Show Google Ma...  >  All threads  >  Debugging a failed input validation  >  (Un) Subscribe thread alerts  
Subject:Debugging a failed input validation
Summary:How can I see why a validation check is not accepting a value?
Messages:3
Author:Ian Holden
Date:2008-05-23 17:59:17
Update:2008-05-26 16:43:48
 

  1. Debugging a failed input validation   Reply   Report abuse  
Picture of Ian Holden Ian Holden - 2008-05-23 17:59:18
I have an form field that I have added with the following code fragment:

$errMsg = $form->AddInput( array(
"TYPE" => "text",
"NAME" => "ReviewDate",
"ID" => "ReviewDate",
"SIZE" => 10,
"VALUE" => "",
"ValidateAsNotEmpty" => 1,
"ValidateRegularExpression" => '^\d\d\d\d-\d\d?-\d\d?$',
"ValidateRegularExpressionErrorMessage" => "Review Date not entered as YYYY-MM-DD",
"ValidationErrorMessage" => "Not a valid Review Date value",
"LABEL" => "Review Da<u>t</u>e",
"ACCESSKEY" => "T"
));

Now, when the value in the field is "2008-11-12" the validation for this field fails. Dumb question 1 is "Can someone see a mistake in the regular expression?".

Question 2 is "Is there a method call or some set of code that I can use to determine how a field value is failing its validation check?". How could I determine why a value isn't passing a check? Or to capture some debug details?

  2. Re: Debugging a failed input validation   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-05-23 19:20:23 - In reply to message 1 from Ian Holden
Javascript only supports POSIX regular expressions, so you cannot use PCRE syntax. Use '^[0-9]{4}-[0-9]{2}-[0-9]{2}$' instead.

You can associate different error messages for each type of validation.

  3. Re: Debugging a failed input validation   Reply   Report abuse  
Picture of Ian Holden Ian Holden - 2008-05-26 16:43:48 - In reply to message 2 from Manuel Lemos
Thanks.

I was thinking this morning that it might be due to the flavour of REGEX that I was using and upon reading your response and testing, I found that to be true.

Appreciate the follow-up.