Welcome Guest, Not a member yet? Register   Sign In
form validation
#1

[eluser]suba[/eluser]
Hi all,

1)If the value has empty , then don't need to show error message.

2)If the value has not empty AND value is not number , then I need to show error message

3) If the value has not empty AND value has alphabet then don't need to show error message.

so How can I use rules?
#2

[eluser]richzilla[/eluser]
Checking if the field is empty is easy:
Code:
if($this->input->post('fieldname') != '')
{
  
}

Then you put your rule inside the if statement (so it will only be run if the filed contains a value of some kind)


You could do with clarifying your validation rules, they're pretty ambiguous (or just plain contradictory):

Your saying you want a error message to be displayed if the value IS NOT a number, yet you are happy to accept alpha characters. Alpha characters aren't numbers?.

Are you trying to prevent punctuation being inserted?
#3

[eluser]LuckyFella73[/eluser]
Why don't you have a look at the user guide? There is a table
describing all possible settings quite clearly.

In your case the rule has to be "alpha"

User Guide:
Form Validation / Rule Reference Table




Theme © iAndrew 2016 - Forum software by © MyBB