赞
踩
- <el-input
- size="small"
- v-model="city"
- placeholder="请输入城市名称"
- @blur="addCity(scope.$index)"
- @keyup.native="btKeyUp"
- @keydown.native="btKeyDown"
- ></el-input>
-
- // methods内
-
- // 只能输入汉字、英文、数字
- btKeyDown(e) {
- e.target.value = e.target.value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5]/g,"");
- },
- //限制输入特殊字符
- btKeyUp(e) {
- e.target.value = e.target.value.replace(/[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/g,"");
- }

在el-input 内 使用 keyup等事件 需要添加 .native 否则无法正常执行事件
下面是 只可输入数字
- <el-input
- size="small"
- v-model="scope.row.order_number"
- v-show="scope.row.isShowInp_order"
- @blur="editOrder(scope.$index,scope.row)"
- v-focus
- @keyup.native="UpNumber"
- @keydown.native="UpNumber"
- class="table_input"
- ></el-input>
-
- // 只可输入数字
- UpNumber(e) {
- e.target.value = e.target.value.replace(/[^\d]/g,"");
- }
限制输入正数 保留两位小数
- <el-input
- v-model="modalForm.invoice_pre_amount"
- placeholder="请输入"
- oninput="value=value.replace(/[^\d.]/g,'').replace(/^\./g, '').replace(/\.{2,}/g, '').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.').match(/^\d*(\.?\d{0,2})/g)[0] || null"
- ></el-input>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。