Welcome Guest, Not a member yet? Register   Sign In
url validation rule in form_validation

i read in user guide, ci does't include url validation rule in form_validation class.
anyone can ignite me to solve this problem? i'm very tired even to searching in google,

thanks Smile

Well, I'm sure CI doesn't include this rule because everyone will have their own idea of what to allow as a url. Like, do you allow underscores, capital letters, etc. Personally I only allow lower-case letters, numbers and dashes.

Its easy to make your own validation rule(s) for your url case and extend Form_validation.

Heres a rule for only lower-case letters, numbers, and dashes
function valid_url($str)
    $this->set_message('valid_url', 'The %s field may only contain lower-case letters, numbers, and dashes.');
    return ( ! preg_match("/^([a-z0-9-'])+$/", $str)) ? FALSE : TRUE;    

yes i did,
i already extend class Form_validation, Big Grin


Theme © iAndrew 2016 - Forum software by © MyBB