Forums

Validation and Checkboxes

pod2010 24 Mar, 2010
Hi,

again two Problems:

1) Validation with my own divs doesn't work.

If you need a custom error message then put it at your field title attribute! e.g: <input name="field1" title="Enter your first name here">



After enabling validation and choosing "Use my own divs", I put the code like this, but it doesn't work. What can I do?

2) I changed the input value for checkboxes, so that, if they are active, the output is "ja". But if they aren't active there's only the input name. How can I change this, that the output, if you don't click, is "nein"?

Thanks for your help.

pod
GreyHead 24 Mar, 2010
Hi pod,

a) Please see the Tooltip. Validation with your own divs requires that you add divs with classes like class='CV_LV_ERROR_field_id' where field_id is the id of the input the message relates to.

b) HTML checkboxes don't work like that. They only ever have a single value and that value is ony returned if the checkbox is checked. Either use a pair of Yes/No radio buttons, or add a PHP check on the returned values after submission and set the values you want.

Bob
pod2010 24 Mar, 2010
Hi,

thanks for your answer. I don't have this tooltip with div-classes.^^ But ok...

Radio Buttons won't work, because in one group of products you can click more than one button. What do you mean with php check? Where can I add this in the extension?
GreyHead 24 Mar, 2010
Hi pod,

The tooltips should be available by hovering over the blue 'i' icons.

You'd need to add code to the OnSubmit Before box to check the results returned from the form, if the checkbox value is there as 'ja' then accept it otherwise set it to 'nein'.
<?php
$check_box = JRequest::getString('check_box', 'nein', 'post');
JRequest::setVar('check_box', $check_box);
?>

Bob
pod2010 24 Mar, 2010
hi,

i tried to add this code to onsubmit - before sending email, but nothing happens. Do I have to change anything in the code?

Thanks for your help.

greetz
GreyHead 24 Mar, 2010
Hi pod,

Well, you need to replace 'check_box' with the name of your checkbox.

Bob
pod2010 24 Mar, 2010
Ah shit, that was my fault. Of course...thanks a lot.

Is it possible that this only works with one checkbox but not with all? Cause I copied the snippet for every checkbox, but it doesn't work?!

greetz
GreyHead 24 Mar, 2010
Hi pod,

It doesn't discriminate, with the code right it will work with all of them.

Bob
This topic is locked and no more replies can be posted.