Last active
December 28, 2015 16:49
-
-
Save neerajsohal/7531865 to your computer and use it in GitHub Desktop.
Validate URLs by extending CodeIgniter Form Validation Library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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