dongyao5186 2011-12-24 16:24
浏览 38
已采纳

CodeIgniter表单验证匹配标签

Is it possible to change the output of the matches call when running form validation in CodeIgniter?

I'm validating a password against a confirm password box.

array(
    'field' => 'userPassword',
    'label' => 'Password',
    'rules' => 'trim|required|matches[userConfPassword]'
)

But when the error is triggered it prints out:

The Password field does not match the userConfPassword field.

The user has no idea was userConfPassword means and I'd like to change that to something more friendly. Reading the docs I can't find a way to do it.

  • 写回答

2条回答 默认 最新

  • dongqin8652 2011-12-24 16:52
    关注

    Well, you can override the default message:

    $this->form_validation->set_message('matches', 'the two passwords do not match|');
    

    or some other message like that :).

    I usually use that message for the "confirm password" only, though, so I set the normal password field as required and that's all, while for the confirm I have it to match the password entered, not the otherway around (or both). But that's just matter of taste I think.

    For the record, it's written in this paragraph of the manual.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序