我想在一个地方验证多个字段。因此,我在一个表格中包含了4个字段 如下
用户至少键入上述任何一个字段。请帮助我获得解决方案,用户键入表单中的任何链接。
答案 0 :(得分:4)
您可以添加自己的验证方法。
public $validate = array(
'facebook_link' => array(
'rule' => array('validateLink'),
'message' => '...'
),
'twitter_link' => array(
'rule' => array('validateLink'),
'message' => '...'
),
'google_plus_link' => array(
'rule' => array('validateLink'),
'message' => '...'
),
'linked_in_link' => array(
'rule' => array('validateLink'),
'message' => '...'
),
);
public function validateLink($link) {
$allFieldsAreEmpty = (
empty($this->data[$this->alias]['facebook_link']) &&
empty($this->data[$this->alias]['twitter_link']) &&
empty($this->data[$this->alias]['google_plus_link']) &&
empty($this->data[$this->alias]['linked_in_link'])
);
return !$allFieldsAreEmpty;
}
答案 1 :(得分:0)
希望这对你有用。
var windowObjectReference = null; // global variable
function showAsReservation(url){
if(windowObjectReference == null || windowObjectReference.closed){
windowObjectReference = window.open(url,
"_blank","toolbar=no,scrollbars=no, resizable=yes,top=500, left=500, width=400, height=400");
}
else
{
windowObjectReference.focus();
};
windowObjectReference.focus();
}