codeigniter alpha_numeric表单验证不接受空间 [英] codeigniter alpha_numeric form validation not accepting space

查看:170
本文介绍了codeigniter alpha_numeric表单验证不接受空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置表单验证,以便用户不能添加像$,@,&;等特殊字符...只允许字母数字字符

i want to set form validation so that user cannot add special characters like $, @, &, etc... only alpha numeric characters are allow

$this->form_validation->set_rules('cat_name', 'Category Name', 'trim|xss_clean|required|is_unique[cht_category.cat_name]|min_length[5]|max_length[75]|alpha_numeric');

当我用空格添加类别名称时,出现以下错误
类别名称字段可能只包含字母数字字符。
当我添加类别名称不带空格或单个单词然后它的工作正常

when i add category name with space then i get following error "The Category Name field may only contain alpha-numeric characters." when i add category name without space or single word then its working fine

推荐答案

使用:

alpha_numeric_spaces

参考: https://www.codeigniter.com/userguide3/libraries/form_validation.html

这篇关于codeigniter alpha_numeric表单验证不接受空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆