【发布时间】:2016-05-16 10:17:49
【问题描述】:
如果用户输入英文字符,则显示一条消息。消息应显示必须输入波斯字符。我为此使用了回调函数,但是当我填写英文字符时,它不会显示消息(please enter %s in persian.)。
这是我的看法:
<div class="row">
<div class="form-group">
<div class="col-md-2">
<label>mantaghe<span style="color:red">*</span></label>
</div>
<div class="col-md-4 col-md-pull-1">
<input class="form-control" id="mantaghe" name="mantaghe"></input>
<?php echo form_error('mantaghe'); ?>
</div>
</div>
</div>
我的控制器:
public function show_info()
{
$this->form_validation->set_rules('mantaghe', 'mantaghe ',
'required|callback_persian_check');
}
function persian_check()
{
$username = $this->input->post('mantaghe');
if (!preg_match('/^[^\x{600}-\x{6FF}]+$/u',$username))
{
$this->form_validation->set_message('persian_check'," please enter %s in persian");
return false;
}
else return true;
}
【问题讨论】:
-
你在说什么?
-
您在方法中编写方法在完成第一个后编写您的方法并使用
$this->METHODNAME访问并添加有关您的问题的更多信息
标签: php codeigniter validation