如何防止元素验证 [英] how to prevent an element to validate

查看:160
本文介绍了如何防止元素验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cakephp框架为我的项目。在我的形式我采取一个复选框点击这两个其他文本框都显示。
通过使用cakephp验证方法我验证表单数据,但我想要当复选框未选中,那么它避免该文本框的验证。它仅在复选框被选中时才会检查。
so plz help me。

hi to all i am using cakephp framework for my project. in on of my form i take a checkbox on click on this two other text box are shown. by using cakephp validates method i validate the form data but i want that when the checkbox is not checked then it avoid the validation for that text box. it check only when the checkbox is checked. so plz help me.

提前感谢

推荐答案

您可以使用您的模型beforeValidate servicecall

You can use your models beforeValidate servicecall for that and add extra validation criteria for this model.

例如:

function beforeValidate($options = array())
{
    if(!empty($this->data['Model']['fieldOne']))
        $this->validate['fieldTwo'] = array(/*normal validation rules*/);
    return true; // Needed or validation fails
}

这篇关于如何防止元素验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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