Welcome Guest, Not a member yet? Register   Sign In
Userdefined Validation Rule
#1

[eluser]singu[/eluser]
I have two problems to create an userdefined validation rule.

problem 1:
----------
I have two fields. Field 1 or Field 2 must be completed.

problem 2:
I have a dropdown with two values "Company" & "Person". If Company is selected in the dropdown, then field vat must be completed.

CodeIgniter 2.1
#2

[eluser]Kamarg[/eluser]
There is no question there. What do you need help with? What have you already done? Do you have relevant code to show?
#3

[eluser]CroNiX[/eluser]
These are pretty easy to do. You can either extend the form validation library with new rules or use callbacks and define the rules in the controller.

For your first one, you would just check to see if $this->input->post('field1') is not empty OR $this->input->post('field2') is not empty.

For the 2nd one, if $this->input->post('dropdown1') has a value, then $this->input->post('dropdown2') must have a value.

There are examples in the user guide on how to create your own callbacks, and also how to extend a CI library. There are also lots of samples in the forums. Beyond that, we would need to see what you have tried so far in order to help more.




Theme © iAndrew 2016 - Forum software by © MyBB