Validation: one of two field required |
Hello.
I have a form in which two fields are related. I want at least one of the two fields to be filled out. It is also conceivable that both are filled in, but not that neither is filled out. Is there a validation rule for this? Or can someone help me with a solution? Greetings, Kigh ...
https://codeigniter.com/userguide3/libra...on-methods
I think you can create your own validation rule for this case. Or you can follow the code below. I think you can do that on CI4 too. PHP Code: if(!isset($_POST['field_one']) and !isset($_POST['field_two'])){
For CI 4:
PHP Code: if($this->request->getPost('field_one') == '' && $this->request->getPost('field_two')){ Where $error_msg contains your error. |
Welcome Guest, Not a member yet? Register Sign In |