Forums

Validate Field to specific values

spanners 04 Jan, 2012
I have set up a form where people can enter one of three voucher codes to claim a prize.

I want the form to put up an error message tooltip if the incorrect code has been entered.

I found this forum post http://chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=26&t=21080&p=69665&hilit=validate+field#p69665 and http://chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=26&t=44281#p194412 and I've gone into the Wizard editor and set the field class to validate['confirm[fieldname]'] but I need it to check if it is equal to one of the three specific codes, not what is in a previous field.

I know I can create a hidden field, but I think the security would be pretty low and then I could only check one code.

How can I validate the field so that if the user puts in the correct code, it lets you submit the form, but if the user puts in the INCORRECT code it gives you a tool tip "Voucher Code Invalid"?
GreyHead 08 Jan, 2012
Hi spanners,

The FormCheck validation code that ChronoForms uses doesn't include a function to check against a list. You could use custom JavaSCript to check against a list in the page code somewhere but - as you say - this isn't too secure. Probably better to use an Ajax check that just has a Yes/No response; then the answers aren't visible at all. This isn't hard to do and you'll find some examples here.

Bob

PS You should probably double check the results in the ServerSide validation just to be sure.
This topic is locked and no more replies can be posted.