Skip to content

Instantly share code, notes, and snippets.

@neerajsohal
Last active December 28, 2015 16:49
Show Gist options
  • Save neerajsohal/7531865 to your computer and use it in GitHub Desktop.
Save neerajsohal/7531865 to your computer and use it in GitHub Desktop.
Validate URLs by extending CodeIgniter Form Validation Library
# My Form Validation Class
# Save this in 'core' folder under 'application' folder
class MY_form_validation extends CI_form_validation {
function valid_url($str){
if(filter_var($str, FILTER_VALIDATE_URL)) {
return TRUE;
} else {
return FALSE;
}
}
}
# In Controller
$this->form_validation->set_rules('field_name', 'field_label', 'valid_url');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment