浏览代码

添加详细地址blur验证

306132416@qq.com 5 年之前
父节点
当前提交
760bf85cae
共有 2 个文件被更改,包括 18 次插入14 次删除
  1. 9 7
      pages/index/customPage/index.vue
  2. 9 7
      pages/index/dealerPage/index.vue

+ 9 - 7
pages/index/customPage/index.vue

@@ -58,7 +58,7 @@
 							</picker> -->
 						</view>
 					<view class="textarea-box" v-show="!addressShow">
-					     <textarea  auto-height   placeholder="请输入详细地址" v-model="addressDetail" maxlength="26" name="detailAddress" />
+					     <textarea  auto-height   placeholder="请输入详细地址" v-model="addressDetail" maxlength="26" @blur="testLength" />
 					 </view>
 			</view>		
 		</view>
@@ -267,6 +267,14 @@
 						  }
 			             
 			          },
+				testLength(){
+					 if(this.addressDetail.length > 25){
+						 uni.showToast({
+							title: '详细地址应为0-25个字符',
+							icon: 'none'
+						 });
+					}
+				}, 	  
 			  formSubmit(e) {
 			  	//将下列代码加入到对应的检查位置
 			  	//定义表单规则
@@ -277,12 +285,6 @@
 			  			errorMsg: "姓名不能为空"
 			  		},
 					{
-						 name: "detailAddress", 
-						 checkType: "string", 
-						 checkRule: "0,25", 
-						 errorMsg: "详细地址应为0-25个字符" 
-					},
-					{
 						name: "trade",
 						checkType: "notnull",
 						errorMsg: "行业不能为空"

+ 9 - 7
pages/index/dealerPage/index.vue

@@ -74,7 +74,7 @@
 			   				</view>
 			   			</view>
 					<view class="textarea-box" v-show="!addressShow">
-					     <textarea  auto-height   placeholder="请输入详细地址" v-model="addressDetail"  name="detailAddress" maxlength="26"/>
+					     <textarea  auto-height   placeholder="请输入详细地址" v-model="addressDetail"  maxlength="26" @blur="testLength"/>
 					 </view>
 			</view>		
 		</view>
@@ -141,6 +141,14 @@
 				 this.txt = data.data.join('')
 				 console.log(data.data.join(''))
 			  },
+			 testLength(){
+				 if(this.addressDetail.length > 25){
+					 uni.showToast({
+					 	title: '详细地址应为0-25个字符',
+					 	icon: 'none'
+					 });
+				 }
+			 }, 
 			  formSubmit(e) {
 			  	//将下列代码加入到对应的检查位置
 			  	//定义表单规则
@@ -150,12 +158,6 @@
 			  			checkType: "notnull",
 			  			errorMsg: "姓名不能为空"
 			  		},
-					{
-						 name: "detailAddress", 
-						 checkType: "string", 
-						 checkRule: "0,25", 
-						 errorMsg: "详细地址应为0-25个字符" 
-					},
 			  		{
 			  			name: "dealerName",
 			  			checkType: "notnull",