<?php
class contactform extends cformmodel
-|\d-)(\d|\d)?$/','message' => '請輸入正確的**號碼.'),
array('fax', 'match','pattern' => '/^(\d-|\d-)(\d|\d)?$/','message' => '請輸入正確的傳真號碼.'),
array('mobile', 'match','pattern' => '/^13[0-9][0-9]$|15[0189][0-9]$|189[0-9]$/','message' => '
請輸入正確的手機號碼.'),
array('email','email','on'=>'edit','message'=>'郵箱輸入有誤.'),
array('zipcode','required','on'=>'edit','message'=>'郵編必須填寫.'),
array('zipcode','numerical','on'=>'edit','message'=>'郵編是6位數字.'),
array('zipcode','length','on'=>'edit','min'=>6,'max'=>6,'tooshort'=>'郵編長度為6位數.','toolong'=>'郵編長度為6
位數.'),
array('website','url','on'=>'edit','message'=>'**輸入有誤.'),
array('qq', 'match','pattern' => '/^[1-9][0-9]$/','message' => '請輸入正確的qq號碼.'),
array('msn','email','on'=>'edit','message'=>'msn輸入有誤.'),);}
}完整示例:
public $password2;//非資料庫的字段,但是在view中需要用到
public $verify; //手機驗證碼
public $fjg; //忘記號碼
/*** 對映資料庫表名
* @return string the associated database table name
* www.shouce.ren
*/public function tablename()
/*** 驗證規則
* @return array validation rules for model attributes.
*/public function rules()
$/','message' => '請輸入正確的經辦人手機號
碼.'),
//array('certificate_id', 'match','pattern' => '/(.jpg|.gif|.png|\d)$/','message' => '請重新選擇證書影象並且後
綴只能是jpg、gif、png格式.'),
array('phone', 'match','pattern' => '/^(\d-|\d-)?(\d|\d)?$/','message' => '請輸入正確的座機號碼.'),
array('fax', 'match','pattern' => '/^(\d-|\d-)(\d|\d)?$/','message' => '請輸入正確的傳真號碼.'),
//array('email_address', 'match','pattern' => '/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/','message' => '請輸入正
確的郵箱.'),
array('email_address','email','message'=>'請輸入正確的郵箱.'),
//驗證密碼和確認密碼
array("password2","compare","compareattribute"=>"password","message"=>"兩次密碼不一致",'on'=>'register'),
array("password2","compare","compareattribute"=>"password","message"=>"兩次密碼不一致",'on'=>'regonter'),
array('qq', 'match','pattern' => '/^[1-9][0-9]$/','message' => '請輸入正確的qq號碼.'),
array('type,certificate_id,company_type, nationality,yyzz_id, status,level,create_by_id,
create_time,update_time', 'numerical', 'integeronly'=>true),
array('verify', 'numerical', 'message' => '驗證碼不正確','integeronly'=>true),
array('name,user_type,tuijianren', 'length', 'max'=>20),
array('password', 'length', 'max'=>100),
array('email_address,business', 'length', 'max'=>50),
array('communication_address,money, yhzh,yhmc,industry, company,
register_address,yhdh,shangbiao,zhuanli,gongshang', 'length', 'max'=>255),
array('role_id','default', 'setonempty'=>true, 'value'=>10),
array('shangbiao','default', 'setonempty'=>true, 'value'=>'0,0'),
array('zhuanli','default', 'setonempty'=>true, 'value'=>'0,0'),
array('gongshang','default', 'setonempty'=>true, 'value'=>'0,0'),
array('password','default', 'setonempty'=>true, 'value'=>'123456'),
/*驗證碼*/
// 'toolarge'=>'檔案大小不能超過10m!',
// 'message'=>'請先上傳證書影象.'
// ),
// the following rule is used by search().
// @todo please remove those attributes that should not be searched.
array('id,role_id,name, password,user_type,
email_address,tuijianren,shangbiao,company_type,zhuanli,gongshang,money,yhzh,yhmc,yyzz_id,yhdh,type,level, phone, qq,
mobile_phone, fax, communication_address, nationality, industry, company, business, register_address, certificate,
status, create_by_id, create_time, update_time', 'safe', 'on'=>'search'),
);}
/** 手機驗證碼校驗
*/public function checkverify($attribute,$params)
else}}
jsp表單驗證大全
表單驗證 表單驗證,可分為 n 在伺服器端驗證表單 n 在客戶端驗證表單 在伺服器端驗證表單,是指通過內建物件request獲取客戶端通過表單提交的資料後,進行驗證。在客戶端驗證表單,是指在客戶端的瀏覽器對使用者輸入的資訊進行合法性驗證,如使用者名稱或密碼是否為空,電子郵件是否含有 和 等字元,身份...
js驗證表單大全
1.長度限制 2.只能是漢字 3.只能是英文 4.只能是數字 5.只能是英文本元和數字 onbeforepaste clipboarddata.setdata text clipboarddata.getdata text replace d g,6.驗證油箱格式 7.遮蔽關鍵字 這裡遮蔽 和 8....
flex 表單驗證大全
1.驗證必填項 代 碼如下 validator元件的功能是檢測必填項。我們把要檢測的元件的名字寫在source屬性中,把要檢測的元件的屬性寫在property屬性中,然後自 定義 requiredfielderror屬性的值即可。當然requiredfielderror屬性的值也可以不定義,那麼就會...