Welcome Guest, Not a member yet? Register   Sign In
how can I allow epmty value in matches[] rule in validation?
#1

[eluser]suba[/eluser]
Hi .

CASE 1
-----------
I used form validation class.

I want to check only value should be either A, B , C , D or empty values.

How can i use in form validation rule in form validation.?

please advise me.

CASE 2
----------
I want to allow empty value and number only.

How can i use this case?
#2

[eluser]WanWizard[/eluser]
Simply do not include 'required' in your rule to allow an empty value. If empty, no further validations will be executed.
#3

[eluser]suba[/eluser]
Hi,

Thanks.

I did not put required in rule.

If the field is empty, there is no error message.

If the field has non empty AND has A or B or C or D there is no error message.

If the filed has non empty and other than A OR B or C or D, there is error message.

I want to check other than empty , A, C ,D values.

Code:
$this->form_validation->set_rules('mark','mark','matches[ABCD]');
#4

[eluser]WanWizard[/eluser]
Me confused. Wink

First, you said you wanted to accept Empty, A, B, C and D as valid. Which is what your rule does. Now you state that you want to do the opposite, ie empty, A, B, C and D means error, all other values are fine?




Theme © iAndrew 2016 - Forum software by © MyBB