CodeIgniter Forums
Using Form Validation with unique dropdown menu selections - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Using Form Validation with unique dropdown menu selections (/showthread.php?tid=22415)



Using Form Validation with unique dropdown menu selections - El Forum - 09-08-2009

[eluser]gscharlemann[/eluser]
I'm importing a csv file and using the first line of the file to compare and match to the column headings of a DB. There can be 10-20 headings csv file and I have the following form:

Code:
<form action="create_race.html" method="post">
<table cellpadding="0" cellspacing="0" border="1">  
  <tr>  
    <td>Place</td>  
    <td><select name="Place">
      <option value="PLACE">PLACE</option>
      <option value="BIB">BIB</option>
      <option value="AGE">AGE</option>
    </select></td>
  </tr>  
  <tr>  
    <td>Age</td>  
    <td><select name="Age">
      <option value="PLACE">PLACE</option>
      <option value="BIB">BIB</option>
      <option value="AGE">AGE</option>
    </select></td>
  </tr>  
  <tr>  
    <td>Bib</td>  
    <td><select name="BIB">
      <option value="PLACE">PLACE</option>
      <option value="BIB">BIB</option>
      <option value="AGE">AGE</option>
    </select></td>
  </tr>
  <tr>
    <td colspan="2">&lt;input type="submit" name="Submit" /&gt;&lt;/td>
  </tr>
</table>
&lt;/form&gt;

Is it possible to use the Form Validation class to ensure that the "PLACE" option is not selected by both the "PLACE" dropdown and the "AGE" dropdown?

Thanks in advance.


Using Form Validation with unique dropdown menu selections - El Forum - 09-08-2009

[eluser]bretticus[/eluser]
You might try adding a rule to the validation class...

Code:
class MY_Form_validation extends CI_Form_validation {    
    
    function not_match($str1, $str2)
    {
            return ( $str1 != $str2  ) ? TRUE : FALSE;
    }    
}



Using Form Validation with unique dropdown menu selections - El Forum - 09-08-2009

[eluser]gscharlemann[/eluser]
Good call. I'll play with that. Thanks