Closed GoogleCodeExporter closed 8 years ago
Thanks moncojhr, what I really did was to verify two form fields that must have
equal value, not type validation.
Thanks
Original comment by geodavis...@gmail.com
on 6 Aug 2010 at 8:09
Is it already possible to use a regex?
I could not find any documentation about it.
Original comment by sven.lar...@gmail.com
on 15 Nov 2010 at 3:09
Maybe you could extend the field prototype to allow the user to pass a
validation array after the options. Then you would create a simple validation
script that would reference a custom library by looking up the "fieldType" and
determining if it is in the acceptable format. If it is, it calls the success
function, if not, it calls the error function. Timeout could also be added
simply by adding the timeout time to the validate array. Then the user would be
responsible for evaluating the errors and reformatting/rejecting the values.
The validate function would be like a simple "filter" to determine if a second
level of error handling was in order.
Presumably, you could validate automatically somehow using the syntax:
$form->addEmail("enter e-mail address",
"emailField",
"",
Array(),
Array("lib"=>rulesurl,
"fieldtype"=>"email",
"success"=>successfunc,
"error"=>errorfunc,
"altformat"=>"userNameOnly",
"timeout"=>30));
and the file located at rulesurl could contain something like
<fieldtype name="email">
<validate><![CDATA[<script>
function (val) { //validates and returns value if valid
or error reference if invalid
}
</script>]]></validate></fieldtype>
If you were to be really crazy about it, you could have the library contain
formatting rules as well so that when the field passed the validation function,
it returned a correctly formatted value (that would be different from the input
value, but more appropriate for the field (i.e. email addresses would be all
lowercase, for example).
Original comment by jasein...@gmail.com
on 6 Jan 2011 at 2:27
Regular expression validation is included in the 2.0 version release. Also,
it's much more feasible to extend the Validation abstract class now compared to
the 1.x branch.
- Andrew
Original comment by ajporterfield@gmail.com
on 14 May 2011 at 3:23
Original comment by ajporterfield@gmail.com
on 14 May 2011 at 3:36
Original issue reported on code.google.com by
moncojhr@gmail.com
on 27 May 2010 at 6:17