Forums

Validation doesn't work with multiple fields

gdpodesta 16 Aug, 2007
Validation seems to work only if there is a single field specified. When putting multiple fields in, separating with commas as instructed, the validation is completely ignored.

I have tried
field1,field2
field1, field2
field1 , field2

and even
field1;field2
field1; field2
field1 ; field2

Still no luck! Am I missing something painfully obvious, or is there a problem here?
Max_admin 16 Aug, 2007
Hi,

this should work: field1,field2

there must be some problem with your code which makes an error into the javascript but testing here works ok, which browser and system do you use ? it even should work ok at most cases.

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
gdpodesta 16 Aug, 2007
Thanks for the quick response; here's the code I'm using, and everything else is pretty much barebones:

<table>
<tr><td colspan="2">Instructions to Bookstore Employee:<Br><br></td></tr>
<tr><td><label for="receipt1">Receipt Number:</label></td><td>
<input type="text" name="receipt1" id="receipt1" size="15" class="inputbox"/></td></tr>
<tr><td><label for="receipt2">Re-Enter Receipt Number:</label></td><td>
<input type="text" name="receipt2" id="receipt2" size="15" class="inputbox"/></td></tr>
<tr><td><label for="coursecount">How many courses were purchased:</label></td><td>
<input type="text" name="coursecount" id="coursecount" size="1" class="inputbox"/></td></tr>
<tr><td><label for="email1">Student Email Address:</label></td><td>
<input type="text" name="email1" id="email1" size="50" class="inputbox"/></td></tr>
<tr><td><label for="email2">Re-Enter Student Email Address:</label></td><td>
<input type="text" name="email2" id="email2" size="50" class="inputbox"/></td></tr>
<tr><td><label for="comments">Special Notes or comments:</label></td><td>
<textarea cols="50" rows="5" name="comments" id="Comments" class="inputbox"></textarea></td></tr>
<tr><td valign="top"> </td><td valign="top">Please enter the characters that you see in the image below<br>{imageverification}</td></tr>
<tr><td></td><td><input type="submit" name="submit" value="Submit Receipt" class="button"/></td></tr>
</table>

Any clues in this?
GreyHead 16 Aug, 2007
Hi Max and gdpodesta,

I notice that these field already have a class attribute, I wonder if there is some conflict in adding another??

Bob
gdpodesta 16 Aug, 2007
Well Bob, you get the "Clever Guy Award" for the day...that did the trick!!! Thanks everyone!
GreyHead 16 Aug, 2007
Hi Both,

Thanks gdpodesta - not feeling so clever with my main PC in for intensive care ;-(

Max, I just looked at the code and I think that the validation needs another little bit of code to search for any existing classes and add them to the validation classes. This is tricky as the class can come before the name so I think you have to identify the string from <. . .>, check if it's a form input, then parse for name and class.

I was thinking anyhow that this might be worth doing for a future version as storing an array of field names as a form parameter would allow select boxes for some of the Form configuration fields.

Of course, this is complicated by the possibility of embedded php . . .

Just a thought.

Bob

Later: I just noticed that the code makes any 'validated field' 'required', I'm not sure that this is quite right either.<br><br>Post edited by: GreyHead, at: 2007/08/16 16:05
gdpodesta 16 Aug, 2007
A little unrelated, but hoping I can get some "free" help. Not much of a developer, which is why I love all this joomla stuff...is there a built in way, or another easy way to validate that one field is the same as another? In the sample code, I'd like to ensure that the receipt number is correctly entered, as well as the email address.
GreyHead 16 Aug, 2007
Hi gdpodesta,

The answer is 'No' and 'Yes'.

'No' because this isn't supported in the current version of ChronoForms.

'Yes' because the functionality does exist in the JavaScript code that Max is using, but it's not completely straight forward. You'll find the reference about half-way down this page. Look for "equalToField :" To enable this you'd either have to hack Max's code in ChronoForms, or probably more simply turn off the ChronoForms validation and add your own using the FAQ here, you'd still need to work out just how to set up this test but that doesn't look too difficult.

Maybe someone else has another suggestion or has done something similar??

Bob

Edited to replace link with tinyurl - link contained the word 'javascript' and was automatically deleted by FirBoard.<br><br>Post edited by: GreyHead, at: 2007/08/16 17:09
gdpodesta 16 Aug, 2007
Thanks again guys....most sincerely appreciated!
This topic is locked and no more replies can be posted.