"Agree" checkbox

ronze 26 Aug, 2008
Hey everyone

I know it has been around the forum in some posts, but I just wanna know the basics :-)

How do I validate whether or not a checkbox is checked?

not checked -> "You have no checked the checkbox"
checked -> send form....

thanks
Max_admin 26 Aug, 2008
add the checkbox name to the validate one required and enable validation in the validation tab!😉
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ronze 26 Aug, 2008
Yeah, I thought that, but it doesn't work

It says something about a group of checkboxes? I just have one? And do I have to add a classname?
Max_admin 26 Aug, 2008
Hi ronze,

just add the checkbox name and dont assign a class to this checkbox unless you have V3, what happens ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ronze 26 Aug, 2008
Hey

Nothing happens if I leave the checkbox empty. All other validation works.
What can be the problem?

Thanks a lot for the support! You guys are the best!

- Rune
Max_admin 26 Aug, 2008
Hi Rune, can I look at your code here ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ronze 27 Aug, 2008
I just read your comment about version 3. I am using version 3.

What do I have to do?

My form code:


  <h1>Kundeoprettelse</h1>
  <p>Udfyld venligst felterne nedenfor for at oprette dig som kunde i vores kartotek. For at have mulighed for registrering bedes du indtaste registreringkodeordet i første felt. Hvis du ikke har füet et registreringskodeord, sü ring venligst til os pü 70 26 83 26.</p>
  <p>
    <label for="regkodeord">Registrerings kodeord<br />
    </label>
    <input type="text" name="regkodeord" id="regkodeord" />
  </p>
  <p>
    <label for="brugernavn">Brugernavn til hjemmesiden</label>
    <br />
    <input name="brugernavn" type="text" id="brugernavn" size="40" />
  </p>
  <p>
    <label for="kodeord">Kodeord til hjemmesiden</label>
    <br />
    <input name="kodeord" type="password" id="kodeord" size="40" />
  </p>
  <p>
    <label for="gentagkodeord">Gentag kodeord</label>
    <br />
    <input name="gentagkodeord" type="password" id="gentagkodeord" size="40" />
  </p>
  <p>
    <label for="firma">Firma</label>
    <br />
    <input name="firma" type="text" id="firma" size="40" />
    </p>
  <p>
    <label for="cvr">CVR Nummer</label>
    <br />
    <input name="cvr" type="text" id="cvr" size="40" />
</p>
  <p>
    <label for="selskabsform">Selskabsform</label>
    <br />
    <input name="selskabsform" type="text" id="selskabsform" size="40" />
  </p>
  <p>
    <label for="adresse">Adresse</label>
    <br />
    <input name="adresse" type="text" id="adresse" size="40" />
  </p>
  <p>
    <label for="postnummer">Postnummer</label>
    <br />
    <input name="postnummer" type="text" id="postnummer" size="40" />
  </p>
  <p>
    <label for="by">By</label>
    <br />
    <input name="by" type="text" id="by" size="40" />
  </p>
  <p>
    <label for="telefonnummer">Telefonnummer</label>
    <br />
    <input name="telefonnummer" type="text" id="telefonnummer" size="40" />
  </p>
  <p>
    <label for="faxnummer">Faxnummer</label>
    <br />
    <input name="faxnummer" type="text" id="faxnummer" size="40" />
  </p>
  <p>
    <label for="email">E-mail</label>
    <br />
    <input name="email" type="text" id="email" size="40" />
  </p>
  <p>
    <label for="kontaktperson">Kontaktperson</label>
    <br />
    <input name="kontaktperson" type="text" id="kontaktperson" size="40" />
  </p>
  <p>
    <label for="branche">Branche</label>
    <br />
    <select name="branche" id="branche">
      <option value="VĂŚlg branche">VĂŚlg branche</option>
      <option value="Maskinhandel">Maskinhandel</option>
      <option value="VVS Installatør">VVS Installatør</option>
      <option value="Service Montør">Service Montør</option>
      <option value="Anden branche">Anden branche</option>
    </select>
  </p>
  <p>
    <label for="brancheandet">Branche (anden)</label>
    <br />
    <input name="brancheandet" type="text" id="brancheandet" size="40" />
  </p>
  <p><input name="salgsbetingelser" type="checkbox" /> Jeg accepterer <a href="index.php?option=com_content&view=article&id=13" target="_blank">salgs og leveringsbetingelserne</a><br /><br />
    <input type="submit" name="submit" id="submit" value="Send" />
  </p>


again, thanks!
Max_admin 27 Aug, 2008
try to put your checkbox inside a div like this :

<div><input name="salgsbetingelser" type="checkbox" /></div>


and of course you enabled validation ? nad added the checkbox name in the validate one required ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ronze 27 Aug, 2008
Yeah, I did it all. I'll give it a try with the div
ronze 28 Aug, 2008
hey again

The div-trick does not work. This is the code I post into my "form code" field, then enable validation and write "salgsbetingelser" in the validate-on-required field. All other validation works. What can be the problem?


  <h1>Kundeoprettelse</h1>
  <p>Udfyld venligst felterne nedenfor for at oprette dig som kunde i vores kartotek. For at have mulighed for registrering bedes du indtaste registreringkodeordet i første felt. Hvis du ikke har füet et registreringskodeord, sü ring venligst til os pü 70 26 83 26.</p>
  <p>
    <label for="regkodeord">Registrerings kodeord<br />
    </label>
    <input type="text" name="regkodeord" id="regkodeord" />
  </p>
  <p>
    <label for="brugernavn">Brugernavn til hjemmesiden</label>
    <br />
    <input name="brugernavn" type="text" id="brugernavn" size="40" />
  </p>
  <p>
    <label for="kodeord">Kodeord til hjemmesiden</label>
    <br />
    <input name="kodeord" type="password" id="kodeord" size="40" />
  </p>
  <p>
    <label for="gentagkodeord">Gentag kodeord</label>
    <br />
    <input name="gentagkodeord" type="password" id="gentagkodeord" size="40" />
  </p>
  <p>
    <label for="firma">Firma</label>
    <br />
    <input name="firma" type="text" id="firma" size="40" />
    </p>
  <p>
    <label for="cvr">CVR Nummer</label>
    <br />
    <input name="cvr" type="text" id="cvr" size="40" />
</p>
  <p>
    <label for="selskabsform">Selskabsform</label>
    <br />
    <input name="selskabsform" type="text" id="selskabsform" size="40" />
  </p>
  <p>
    <label for="adresse">Adresse</label>
    <br />
    <input name="adresse" type="text" id="adresse" size="40" />
  </p>
  <p>
    <label for="postnummer">Postnummer</label>
    <br />
    <input name="postnummer" type="text" id="postnummer" size="40" />
  </p>
  <p>
    <label for="by">By</label>
    <br />
    <input name="by" type="text" id="by" size="40" />
  </p>
  <p>
    <label for="telefonnummer">Telefonnummer</label>
    <br />
    <input name="telefonnummer" type="text" id="telefonnummer" size="40" />
  </p>
  <p>
    <label for="faxnummer">Faxnummer</label>
    <br />
    <input name="faxnummer" type="text" id="faxnummer" size="40" />
  </p>
  <p>
    <label for="email">E-mail</label>
    <br />
    <input name="email" type="text" id="email" size="40" />
  </p>
  <p>
    <label for="kontaktperson">Kontaktperson</label>
    <br />
    <input name="kontaktperson" type="text" id="kontaktperson" size="40" />
  </p>
  <p>
    <label for="branche">Branche</label>
    <br />
    <select name="branche" id="branche">
      <option value="VĂŚlg branche">VĂŚlg branche</option>
      <option value="Maskinhandel">Maskinhandel</option>
      <option value="VVS Installatør">VVS Installatør</option>
      <option value="Service Montør">Service Montør</option>
      <option value="Anden branche">Anden branche</option>
    </select>
  </p>
  <p>
    <label for="brancheandet">Branche (anden)</label>
    <br />
    <input name="brancheandet" type="text" id="brancheandet" size="40" />
  </p>
  <div><input name="salgsbetingelser" type="checkbox" /></div> Jeg accepterer <a href="index.php?option=com_content&view=article&id=13" target="_blank">salgs og leveringsbetingelserne</a><br /><br />
    <input type="submit" name="submit" id="submit" value="Send" />
 
Max_admin 28 Aug, 2008
try to add another checkbox inside the div with the same name and see if it works ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ronze 28 Aug, 2008
It still doesn't work. The form submits whether or not they are checked.

can anyone post an example of a form with a single checkbox that works with validation one rewuired?
ronze 01 Sep, 2008
This thing is really, really driving me crazy. I just can't validate the checkbox.

Even though I do everyting that worked in that other thread, it doesn't work...
ronze 01 Sep, 2008
I edited my e-mail template and I can see that the checkbox says "on" when it's checked and nothing if it's not checked.

Another funny thing is, that the Joomla Registration doesn't work when the checkbox is checked.... which actually makes everything useless.
Max_admin 01 Sep, 2008
Hi ronze,

do you have V3.0 Beta 2 ? I suggest you don't do JS validation for this checkbox and do server side one ? there is an example there at the bottom, let me know if this is fine, if not then I will try to go with you into some hack, I didn't test it before but we will try to get it to work!

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ramomu 05 Dec, 2008
hi Admins!

I am having exactly the same problem as Ronze.

Can anyone hlep to resolve?

When I choose the vlaidation library as Prototype... none of the validation works and it submits... But, if make the library as mootools only the Checkbox vlaidation doesnt work....

Please help at your earliest convenience

Thanks
ramomu
GreyHead 05 Dec, 2008
Hi Ramomu,

Have you got ChronoForms v3.0 stable installed?

Prototype does not usually work with Joomla 1.5.x as MooTools is installed by Joomal and the two conflict.

What validation are you trying to use? I don't think that 'required' will work with a checkbox. 'validate-one-required' should be OK though.

Bob
ronze 16 Oct, 2009
I'm now working on another project and the validation of a single checkbox is still not working at all - although I'm running version 5.1 RC5.

Anyone around that can post a simple example on how to validate 1 single checkbox???
GreyHead 16 Oct, 2009
Hi ronze,

This version works fine in RC5.5
<div class="form_item">
  <div class="form_element cf_checkbox">
    <label class="cf_label" style="width: 150px;">Click Me to Edit</label>
    <div class="float_left">
      <input value="check 1" title="" class="radio validate-one-required" id="check00" name="check0[]" type="checkbox" />
      <label for="check00" class="check_label">check 1</label>
    </div>
   </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Submit" name="button_2" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>
Validation set to 'Yes' but nothing else special.

Bob
ifritz 29 Oct, 2009
Same problem here. Current version of CF, but i can not validate
a single checkbox like it does with a text input(mootools).
I do it now with server side validation. Isn't that good in combination
with the captcha, but works for now....
GreyHead 29 Oct, 2009
Hi ifritz,

Please read the post before yours where there is working code to do just that.

Bob
ifritz 30 Oct, 2009
Hi Bob,

i did try the whole post and some combinations, believe me.
It's ok for me though.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger