CodeIgniter Forums

Full Version: Regular Expression test or form validation for login
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]quibstar[/eluser]
I'm trying to have my login require at least one number, special character. But I don't see any way to use regular expression or form validation to accomplish this.

El Forum

[eluser]whobutsb[/eluser]
[quote author="quibstar" date="1262898363"]I'm trying to have my login require at least one number, special character. But I don't see any way to use regular expression or form validation to accomplish this.[/quote]

I'm not a RegExp whiz but you can check out this tutorial for more info on Regular expressions.


As for the validation you can use callbacks

Code:
function myfunction(){

    $this->load->library('form_validation');

    $this->form_validation->set_rules('username', 'Username', 'callback_username_check');
    
    if(!$this->form_validation->run()){
        //Failed
        return;
    }
    
    //Success
    
}


function username_check($username){
    
    //Run your regexp function here
    
    //Return TRUE or FALSE
    
}