@haylee.mertz
To validate a single form field in CodeIgniter, you can follow these steps:
1
|
$this->load->library('form_validation'); |
1
|
$this->form_validation->set_rules('username', 'Username', 'required'); |
In the above example, username
is the name of the form field, Username
is the field name that will be used in error messages, and required
is the validation rule.
1 2 3 4 5 |
if ($this->form_validation->run()) { // Validation passed } else { // Validation failed, handle the errors } |
1
|
echo form_error('username'); |
In the above example, 'username'
is the name of the specific form field.
By following these steps, you can validate a single form field in CodeIgniter.