[SOLVED] Validating dropdown boxes

antonitus

Member
I have an issue when I add validation to a dropdown box. The validation plugin is 'notempty'.

Here is my example:
I have a dropdown box that holds titles, such as Mr, Mrs, Miss, etc. I also have another value with 'Please Select' value. Anyway as the value is already selected in the form, it does not validate the form to tell the user to select the values, Mr, Mrs, Miss, etc. It assumes the 'Please Select' is a valid selected value., which is of course logical.

Is there are way to solve this to tell the form to ignore 'Please Select', i.e. to see it as an empty value? I know that if I was to do this in the HTML code, I could just add 'not selected' to the dropdown tag. I see from the dropdown element, that there is a checkbox to say whether a value is default or not and I assumed, by not checking this on the first value (Please Select), that it would not be selected as a value in the frontend form.

Any suggestions here? Do I need some Javascript/PHP code to overcome this or am I doing something wrong?

Thanks, Tony

Fabrik V3.3.2 - Joomla V3.4.1
 
Hi

I would use PHP validation plugin instead of the noempty.
If we suppose that the value of the 'Please select' is '-' then you apply the PHP validation and in the php code you put:

Code:
return $data != '-';

This will prevent the form to be saved with 'Please select' and the user needs to select one from the other values.
 
Hi dimoss,

This PHP statement worked a treat.

The 'Please Select' was a value of 'Title', instead I replaced it with '-', which is what I had initially, it's simpler.

Thank you very much. I much appreciate your help and time.
Tony
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top