I’m trying to find an effective way to validate the following:
I have 3 form fields, a select menu a checkbox and a textfield. They can
all be left blank on submission, but if you select two or more it
should prompt an error. If the user chooses to, only one field should
be allowed to be submitted.
I tried the following but it seems to be breaking my cucumber scenario.
Only the first if statement works. The rest are breaking the scenario.
if !database.blank? and !auto_generate_database.blank? and
!snapshot_id.blank?
errors[:Database_Selection] = msg
elsif !database.blank? and !auto_generate_database.blank?
errors[:Database_Selection] = msg
elsif !snapshot_id.blank? and !database.blank?
errors[:Database_Selection] = msg
elsif !auto_generate_database.blank? and !snapshot_id.blank?
errors[:Database_Selection] = msg
end
Any input is greatly appreciated.