1

On my website, I have a form that includes CKEditor, and input field for numeric value. Now, sometimes, when I try to submit form, validator is saying, that numeric input field is not in a proper range. The problem is, that the range is set to 1-1000, and I am setting the value that is within this range. So it is totally ignoring my input and assuming that there is nothing. The main problem with that behavior is, that most of the times this works okay (I mean it is validating correctly). But like 10% of the times, it is doing those weird things, and console is throwing no errors... Has anyone had similar problems?

Is it maybe possible to turn off jquery validation for single input field?

Edit: here is my input field:

<input class="text-box single-line" data-val="true" data-val-number="The field Price must be a number." data-val-range="The field Price must be between 1 and 1000." data-val-range-max="1000" data-val-range-min="1" data-val-required="The Price field is required." id="Price" name="Price" type="number" value="0">
4

1 回答 1

1

对我来说看起来像是一个 mvc 输入。我假设您在某处使用它:@Html.ValidationFor( m => m.Price )如果您希望完全删除验证,您可以省略它。

如果不是这种情况,那么只需从元素中删除数据注释

<input id="Price" name="Price" value="0" />

但是,我认为您还应该考虑允许范围为 0-100将初始值设置为1. 原因是现在如果有人在没有输入的情况下点击提交,那么该字段的值将是0,这将导致 的范围验证失败1-100

于 2013-04-25T21:03:55.883 回答