CodeIgniter Forums
Regular Expression test or form validation for login - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Regular Expression test or form validation for login (/showthread.php?tid=26160)



Regular Expression test or form validation for login - El Forum - 01-07-2010

[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.


Regular Expression test or form validation for login - El Forum - 01-07-2010

[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
    
}