這裏我已經驗證,如果任何人輸入超過6位數字後提交,他將得到消息'不超過6位!!'但在這裏我想做一個另一個驗證,發送數據的用戶將可以在字段中輸入超過六個字符。我可以如何解決它?cakephp字段輸入限制
這裏我的模型代碼
public $validate = array(
'name' => array(
'rule' => array('notempty'),
'message' => 'Name is required and cannot be empty!!!',
'required' => true,
),
'ssc_roll' => array(
'rule' => array('notempty'),
'message' => 'S.S.C Roll is required and cannot be empty!!!',
'rule' => array('maxLength', 6),
'message' => 'Not more than 6 digits!!',
'required' => true,
),
'hsc_roll' => array(
'rule' => array('notempty'),
'message' => 'H.S.C Roll is required and cannot be empty!!!',
'rule' => array('maxLength', 6),
'message' => 'Not more than 6 digits!!',
'required' => true,
),
'date_of_birth' => array(
'rule' => array('date'),
'message' => 'Enter a valid date.',
'required' => true,
),
'mobile' => array(
'rule' => array('notempty'),
'message' => 'Enter a valid mobile number.',
'required' => true,
)
);
,並在此視圖代碼
<div class="control-group">
<label class="control-label" for="name">S.S.C Roll *</label>
<div class="controls">
<?php
echo $this->Form->input('ssc_roll', array('class'=>'input-large'));
echo $this->Form->error('ssc_roll'); ?>
</div>
</div>
<div class="control-group">
<label class="control-label" for="name">H.S.C Roll *</label>
<div class="controls">
<?php echo $this->Form->input('hsc_roll', array('class'=>'input-large'));
echo $this->Form->error('hsc_roll'); ?>
</div>
</div>
哪裏是在給定的代碼中的6個位數驗證?無論如何,如果您確定了「數字<7」的驗證並且您希望用戶能夠編寫更多內容,只需刪除驗證? – Sugar
我剛剛編輯了我的code.Here驗證code.Here我希望用戶將被啓用輸入字段中輸入超過6位數字。 –