Codeigniter validate required field,email and passwords.
As you can see we can use "required" for any kind of input type.
Then we have to call controller and check set the validation rules.
Then we can use set_rules() method to set rules.In this method we can pass three parameters.
- The field name - the exact name you've given the form field.
- A "human" name for this field, which will be inserted into the error message. For example, if your field is named "user" you might give it a human name of "Username".
- The validation rules for this form field.
Validation Rules:
trim:
It removes white space from the beginning and end of an input string.
required:
Checks that the resulting string is non-empty
valid_email:
Checks that it is a valid email address
xss_clean:
removes malicious data.
matches[]:
The password field must match the password confirmation field.
If user done any mistake we can identify that and simply use set_message() function to display error message.
0 comments:
Post a Comment