Hello All,

I have created a content type using some CCK fields. I have one "Select List" field where I have given first option as "[select]". I want to validate form so user should not be able to submit the form if [select] is active. How can I validate this field so user can only submit if selected index is not zero. I mean first option is not selected.

Thanks

Comments

CMS’s picture

There should be an checkbox to make the cck field required, in the field setting. Go to your content type, click on manage field, for your select list, you should find a chaect box there.

Geemi’s picture

Thank you very much for your response.

Yes, I have checked that box but requirement is that user should not select first option which is [select], user should select 2nd, 3rd or 4th option.

Geemi’s picture

Fixed:

It was really easy and worked.

I have typed values and labels for select list as follows:

|[select]
1|Male
2|Female

Please note I have not given any value for first label [select] and marked this field as required. I also did not select any value as default. When you will open then form, fist row which has no value is selected and when you will submit the form, system will return error that value is required.

Thanks for help

CMS’s picture

Hi Geemi,
You dont actually need to have to first row with no value, in manage fields select the type as List(text) and the widget as "select list", in the allowed list only add the options you need and mark the field as required and save.
Now when you create the content you will automatically get a "select a value".

robertgarrigos’s picture

I'm doing this but not getting any "select a value" element in the list added automatically. I had to use a first value without key.