简体   繁体   中英

codeigniter realtime form validation

I wanting to validate my forms via ajax (jquery library). Basically I have a form, that takes a password, this needs to be a minimum of 6 letters longs.

Currently I have the validation rule set as this,

$this->form_validation->set_rule('password', 'passswprd', 'required|min_length[6]|trim')

This works fine when submitted using traditional submition through PHP and POST.

However is there a way I can run my validation each time the users changes that field they are focused on?

$(".field_id").live("blur", function(){ ajax call goes here });

You might want to just do the password validation with javascript though, since it shouldn't require serverside work. I'd do a final test with php, but generating traffic for a simple length check seems less than optimal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM