1. 程式人生 > >iview 表單驗證

iview 表單驗證

light cli NPU hold rule cal ack err javascrip

<modal v-model="modelPassWord" width="520" title="修改密碼"
		:mask-closable="false"> <i-form :label-width="100"
		ref=‘formItemP‘ :model="formItemP" :rules=‘ruleValidateP‘> <form-item
		label="請輸入舊密碼" prop="oldPwd"> <i-input
		placeholder="請輸入舊密碼" v-model="formItemP.oldPwd" name=""></i-input> </form-item> <form-item
		label="請輸入新密碼" prop="newPwd"> <i-input
		placeholder="請輸入新密碼" v-model="formItemP.newPwd"></i-input> </form-item> <form-item
		label="重新輸入密碼" prop="repeatPwd"> <i-input
		placeholder="重新輸入密碼" v-model="formItemP.repeatPwd"></i-input> </form-item> </i-form>
	<div slot="footer">
		<i-button type="ghost" @click="pwdModelCancel">取消</i-button>
		<i-button type="error" @click="pwdModelOk(‘formItemP‘)">確定</i-button>
	</div>
	</modal>

  

	//修改密碼驗證
			formItemP: {
				oldPwd: "",
				newPwd: "",
				repeatPwd: ""
			},
			ruleValidateP: {
				oldPwd: [{
					required: true,
					message: ‘請輸入舊密碼‘,
					trigger: ‘blur‘
				}],
				newPwd: [{
					required: true,
					message: ‘請輸入新密碼‘,
					trigger: ‘blur‘
				}],
				repeatPwd: [{
					required: true,
					trigger: ‘blur‘,
					validator:function(rule, value, callback){
	                    if (value == ‘‘) {
	                        return callback(new Error(‘請再次輸入密碼‘));
	                    } else if (value != logoApp.formItemP.newPwd) {
	                        return callback(new Error(‘兩次密碼不一致‘));
	                    } else {
	                        callback();
	                    }
	                }
				}]
			}

		}

  

iview 表單驗證