二手车交易,售价输入0开头时,后边不允许输入任何数字

This commit is contained in:
2025-03-25 14:15:57 +08:00
parent fc4cbbed7a
commit 321414ad87
2 changed files with 12 additions and 9 deletions

View File

@ -272,10 +272,11 @@ export default {
}, },
methods:{ methods:{
validatePrice(value) { validatePrice(value) {
if (/^0+$/.test(value)){ if (value?.startsWith(0) && value?.length > 1) {
value = '0'; this.$nextTick(() => {
this.form.minPrice = 0
})
} }
this.form.minPrice = value;
}, },
clearStorageFormInfo(){ clearStorageFormInfo(){
localStorage.setItem("carSourceFormInfo",'') localStorage.setItem("carSourceFormInfo",'')

View File

@ -173,16 +173,18 @@ export default {
}, },
methods:{ methods:{
validatePrice(value) { validatePrice(value) {
if (/^0+$/.test(value)){ if (value?.startsWith(0) && value?.length > 1) {
value = '0'; this.$nextTick(() => {
this.form.minPrice = 0
})
} }
this.form.minPrice = value;
}, },
validatePrice1(value) { validatePrice1(value) {
if (/^0+$/.test(value)){ if (value?.startsWith(0) && value?.length > 1) {
value = '0'; this.$nextTick(() => {
this.form.maxPrice = 0
})
} }
this.form.maxPrice = value;
}, },
clearStorageFormInfo(){ clearStorageFormInfo(){
localStorage.setItem("wantBuyFormInfo",'') localStorage.setItem("wantBuyFormInfo",'')