Making a select box a required field

Conyard 07 Oct, 2011
Hi, I am currently working on a form where I want to have a select box with an empty value displaying "Please choose" so the user can then select the value that they want from a select box. I also want to make this field a required field. The code I am currently using is:

<select size="1" label_over="0" hide_label="0" class="validate['required']" title="" type="select" name="order_id"><option value="">Please Choose</option></select>


Within here I have included the class="validate['required']" which should make a field a required field and should stop a user from using submitting data.

I have tried to submit data on the front end using chronoforms and the form still submits with no data selected or entered.

Is there something I am missing here? any help with this particular problem would be greatly appreciated!
GreyHead 09 Oct, 2011
Hi conyard,

It should be OK, I just ran a test using the CFv4 wizard and that validates correctly. The Form HTML for the select box was
<div id="label_text_container_div" class="ccms_form_element cfdiv_select">
  <label>Label Text</label>
  <select name="input_select_0" type="select" title="" class=" validate['required']" hide_label="0" label_over="0" size="1">
    <option value="">Please choose</option>
    <option value="No">No</option>
    <option value="Yes">Yes</option>
  </select>
  <div class="clear"></div>
  <div id="error-message-input_select_0"></div>
</div>

Bob
Conyard 10 Oct, 2011
Thanks so much grey head, I knew I was doing something wrong my code was:

class="validate['required']"


when I needed a space in between in order the the validation to work like:

class=" validate['required']"


Thanks again for getting back to me so quickly, I am enjoying using chronoforms at the moment and with dedicated support like this I would not want to use any other product for creating forms within Joomla.
GreyHead 10 Oct, 2011
Hi Conyard,

Good catch - I didn't know that the space was required :-(

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