PHP Classes

Conditional 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  >  Conditional validation  >  (Un) Subscribe thread alerts  
Subject:Conditional validation
Summary:How do I conditionally validate that a field is not empty?
Messages:2
Author:Vassili Gorshkov
Date:2007-02-19 20:37:14
Update:2007-02-27 05:57:56
 

  1. Conditional validation   Reply   Report abuse  
Picture of Vassili Gorshkov Vassili Gorshkov - 2007-02-19 20:37:14
Hi,

Sorry for a simple question, but I am trying to put together a form, where some fields may be empty depnding on the value of other fields. For example,

F1 Sex: ___

F2 Maiden Name (if female): ____


I was considering using a java script custom validation function for F2, but it takes F2's value as an argument. If the whole form was passed to the function, this would be easy. Perhaps, I should just look up the form values from the DOM interface. Does it sound right?

Thanks,

Vas Gorshkov

  2. Re: Conditional validation   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-02-27 05:57:56 - In reply to message 1 from Vassili Gorshkov
That is a very specific type of validation.

It is hard to support all possible types of validation that you may want without bloating further the main forms class.

My recommendation is that you develop a new custom plug-in class to perform that special validation that you want.

I have just submitted an example plug-in class that implements a new custom validation type. You can learn how to implement your custom validation type from that example. Just let me know if you have other difficulties.