ant-design-vue icon indicating copy to clipboard operation
ant-design-vue copied to clipboard

input-number cannot be automatically cleared when the input value is not within the range

Open XiaoRIGE opened this issue 4 years ago • 4 comments

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.

Version

2.2.6

Environment

ant-design-vue:2.2.6 vue:3.0.0

Reproduction link

Edit on CodeSandbox

Steps to reproduce

需求是当输入值不在范围内则清空表单值

What is expected?

输入值不在范围内,清空表单,保持聚焦

What is actually happening?

输入值不在范围内,如果未失焦,视图中的值未发生改变;如果失焦,则显示正常

XiaoRIGE avatar Aug 17 '21 09:08 XiaoRIGE

临时方案

inputNumber.value.blur();
        nextTick(() => {
          valueRef.value = '';
          inputNumber.value.focus();
        });

tangjinzhou avatar Aug 18 '21 09:08 tangjinzhou

Form validation rules are not working for min and max range validation, if the typed value exceeds the max value it returns max value in the validation rule that's it not give any error.

Is there any way to apply the min max validation rule and display an error in form validation for InputNumber?

gangwar1 avatar Oct 25 '23 15:10 gangwar1

Form validation rules are not working for min and max range validation, if the typed value exceeds the max value it returns max value in the validation rule that's it not give any error.

Is there any way to apply the min max validation rule and display an error in form validation for InputNumber?

I have the same issuse!

vbnew avatar Jul 07 '25 02:07 vbnew

i find a solution:

<a-input-number :disabled="record.disable" placeholder="请输入" v-model:value="text.xybhd" @blur="(e) => checkValue(e.target.value, 70, 100)" :min="70" :max="100" />

function checkValue(value, min, max) { console.log(value, min, max) const flag = value < min || value > max if (flag) { message.warning('数值异常,请确认或重新输入') } }

vbnew avatar Jul 07 '25 02:07 vbnew