ElementUIフォームの検証(パスワードの変更)

10943 ワード

ElementUIフォームの検証(パスワードの変更)

		<el-form :model="resetForm" status-icon :rules="resetFormRules" ref="resetForm" label-width="100px">
	            <el-form-item label=" " prop="newpwd">
	                <el-input type="password" v-model="resetForm.newpwd" auto-complete="off"></el-input>
	            </el-form-item>
	            <el-form-item label=" " prop="renewpwd">
	                <el-input type="password" v-model="resetForm.renewpwd" auto-complete="off"></el-input>
	            </el-form-item>
         </el-form>
		data(){			
				var validatePass = (rule, value, callback) => {
					if (!value) {
						callback(new Error(' '));
					} else if (value.toString().length < 6 || value.toString().length > 18) {
						callback(new Error(' 6 - 18 '))
					} else {
						callback();
					}
				};
				 var validatePass2 = (rule, value, callback) => {
	                if (value === '') {
	                callback(new Error(' '));
	                } else if (value !== this.resetForm.newpwd) {
	                callback(new Error(' !'));
	                } else {
	                callback();
	                }
	            };
	            return(){
	            	// 
                resetForm: {
                    newpwd: '',
                    renewpwd: '',
                },
                resetFormRules: {
                    newpwd: [
                        { required: true, validator: validatePass, trigger: 'blur' }
                    ],
                    renewpwd: [
                        { required: true, validator: validatePass2, trigger: 'blur' }
                    ]
                },
                
	            }
            },